1.88.0 • Published 5 years ago

hud-ai v1.88.0

Weekly downloads
2
License
MIT
Repository
github
Last release
5 years ago

HUD.ai Javascript Client

Version Build Status Downloads Try on RunKit

A JavaScript interface to the Hud.ai API. To get started install via npm:

npm install --save hud-ai

Getting Started

First, you'll need to register a client application. This can currently only be done by reaching out to the engineering team.

Single Page Apps

const HudAi = require('hud-ai');

const client = HudAi.create({
  clientId: 'CLIENT_ID',
  redirectUri: 'http://www.example.com/oauth/callbacks/hud-ai'
});

// Send the user to the authorization URL, where they can choose to grant your
// app permissions to access the service on their behalf (if permission has
// already been given, they'll automatically be redirected)
window.location = client.getAuthorizeUri('token');

// token will be returned as the query param `authToken` to your redirect URL
const querystring = require('query-string');
const parsed = querystring.parse(location.hash);
client.setAccessToken(parsed.access_token);

NOTE: The process of token retrieval will need to be performed again when the token becomes invalid (they're currently valid for 30 days).

Server Applications

Because servers can be trusted to keep a secret, setup is much more straightforward.

Client Authentication:

const HudAi = require('hud-ai');

const client = HudAi.create({
  clientId: 'CLIENT_ID',
  clientSecret: 'CLIENT_SECRET'
});

Acting on behalf of a user:

const redirectUrl = client.getAuthorizeUri('code');

// Send the user to the authorization URL, where they can choose to grant your
// app permissions to access the service on their behalf (if permission has
// already been given, they'll automatically be redirected)

// the code to exchange will be returned as the query param `code` to your
// redirect URL
const querystring = require('query-string');
const parsed = querystring.parse(location.search);
client.setAuthorizationCode(parsed.code);

Parameters

ParameterUsageExample
clientId*Registered Client ID'46ef9d9b-89a9-4fd2-84cf-af6de31f2618'
clientSecretRegistered Client Secret'59170c3e-e2c9-4244-92d8-c3595d4af325'
baseApiUrlSpecify an alternate server to request resources from'https://stage.api.hud.ai/v1'
baseAuthUrlSpecify an alternate server to request auth tokens from'https://stage.accounts.hud.ai'
redirectUriPath to redirect auth requests to (required for #get_authorize_uri)'https://app.example.com/oauth/callbacks/hud-ai'
requestaxios is used under the hood, pass a config through here

Basic Usage

client.articles.get('SOME_ARTICLE_ID')
  .then(article => console.log(article))
  .catch(err => console.log('Got an error!', err));

Resources

Notes

  • * and bolded Type indicates required param
  • All list resources have a max of 50 elements per request (e.g. limits higher than that will have no effect)
EntityMethod Base
Articleclient.articles
ArticleHighlightsclient.articleHighlights
ArticleKeyTermclient.articleKeyTerms
ArticleTagclient.articleTags
Companyclient.companies
CompanyEventclient.companyEvents
CompanyIndustryclient.companyIndustries
CompanyKeyTermclient.companyKeyTerms
CompanyProfileclient.companyProfile
Domainclient.domains
Industryclient.industries
KeyTermclient.keyTerms
Personclient.people
PersonKeyTermclient.personKeyTerms
Quoteclient.quotes
Sourceclient.sources
TextCorpusclient.textCorpora
Tweetclient.tweets
Userclient.users
UserCompanyclient.userCompanies
UserCompanyGroupclient.userCompanyGroups
UserContactclient.userContacts
UserDigestSubscriptionclient.userDigestSubscriptions
UserKeyTermclient.userKeyTerms
UserSourceclient.userSources
UserTemplateclient.userTemplates
Videoclient.videos
1.88.0

5 years ago

1.87.0

5 years ago

1.86.0

5 years ago

1.85.0

5 years ago

1.84.0

5 years ago

1.83.0

5 years ago

1.82.0

5 years ago

1.81.0

5 years ago

1.80.0

5 years ago

1.78.0

5 years ago

1.77.0

5 years ago

1.76.3

5 years ago

1.76.1

5 years ago

1.75.0

5 years ago

1.74.0

5 years ago

1.73.0

5 years ago

1.72.4

5 years ago

1.72.3

5 years ago

1.72.2

5 years ago

1.72.0

5 years ago

1.71.0

5 years ago

1.70.0

5 years ago

1.69.0

5 years ago

1.68.0

5 years ago

1.67.0

5 years ago

1.66.0

5 years ago

1.65.0

5 years ago

1.64.0

5 years ago

1.60.0

5 years ago

1.59.0

5 years ago

1.58.0

5 years ago

1.57.0

5 years ago

1.56.0

5 years ago

1.55.0

6 years ago

1.54.0

6 years ago

1.53.0

6 years ago

1.52.0

6 years ago

1.51.0

6 years ago

1.50.1

6 years ago

1.50.0

6 years ago

1.49.1

6 years ago

1.49.0

6 years ago

1.48.0

6 years ago

1.47.0

6 years ago

1.46.0

6 years ago

1.45.1

6 years ago

1.45.0

6 years ago

1.42.0

6 years ago

1.41.0

6 years ago

1.40.0

6 years ago

1.39.1

6 years ago

1.39.0

6 years ago

1.38.1

6 years ago

1.38.0

6 years ago

1.37.2

6 years ago

1.37.1

6 years ago

1.37.0

6 years ago

1.36.0

6 years ago

1.35.2

6 years ago

1.34.2

6 years ago

1.34.1

6 years ago

1.33.1

6 years ago

1.33.0

6 years ago

1.32.0

6 years ago

1.31.3

6 years ago

1.31.2

6 years ago

1.31.1

6 years ago

1.31.0

6 years ago

1.30.5

6 years ago

1.30.4

6 years ago

1.30.3

6 years ago

1.30.2

6 years ago

1.30.0

6 years ago

1.29.0

6 years ago

1.28.0

6 years ago

1.27.3

6 years ago

1.27.2

6 years ago

1.27.1

6 years ago

1.27.0

6 years ago

1.26.2

6 years ago

1.26.1

6 years ago

1.26.0

6 years ago

1.25.0

6 years ago

1.24.0

6 years ago

1.23.0

6 years ago

1.22.2

6 years ago

1.22.1

6 years ago

1.22.0

6 years ago

1.21.2

6 years ago

1.21.1

6 years ago

1.21.0

6 years ago

1.20.0

6 years ago

1.19.0

6 years ago

1.18.0

6 years ago

1.17.0

6 years ago

1.16.0

6 years ago

1.15.1

6 years ago

1.15.0

6 years ago

1.14.0

6 years ago

1.13.0

6 years ago

1.12.5

6 years ago

1.12.4

6 years ago

1.12.3

6 years ago

1.12.2

7 years ago

1.12.1

7 years ago

1.12.0

7 years ago

1.11.2

7 years ago

1.11.1

7 years ago

1.11.0

7 years ago

1.10.1

7 years ago

1.10.0

7 years ago

1.9.6

7 years ago

1.9.5

7 years ago

1.9.4

7 years ago

1.9.3

7 years ago

1.9.2

7 years ago

1.9.1

7 years ago

1.9.0

7 years ago

1.7.0

7 years ago

1.8.0

7 years ago

1.6.1

7 years ago

1.6.0

7 years ago

1.5.4

7 years ago

1.5.3

7 years ago

1.5.2

7 years ago

1.5.1

7 years ago

1.4.1

7 years ago

1.4.0

7 years ago

1.3.1

7 years ago

1.3.0

7 years ago

1.2.5

7 years ago

1.2.3

7 years ago

1.2.2

7 years ago

1.2.1

7 years ago

1.1.0

7 years ago

1.0.8

7 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago