Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

hud-ai

Package Overview
Dependencies
Maintainers
1
Versions
139
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hud-ai

Hud.ai API Client

  • 1.88.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
13
increased by62.5%
Maintainers
1
Weekly downloads
 
Created
Source

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

Keywords

FAQs

Package last updated on 14 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc