Socket
Socket
Sign inDemoInstall

voatapi

Package Overview
Dependencies
50
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    voatapi

voat API wrapper for Node.js


Version published
Weekly downloads
1
Maintainers
1
Created
Weekly downloads
 

Readme

Source

Voat API for Node.js

Compatible with Voat Version: 1.0.5638.22054

Usage

Credentials

First make sure you export your voat credentials to environment variable like so:

export VOATURL="https://www.voat.co"
export VOATAPIPATH="/api/v1"
export VOATAPIKEY="<YOUR_API_KEY>"
export VOATUID="<YOUR_VOAT_USER_ID>"
export VOATPWD="<YOUR_VOAT_PASSWD>"

IMPORTANT: NEVER EVER COMMIT YOUR CREDENTIALS TO PUBLIC

A good way to do this is to include the shell script you use to .gitignore

API Token

Next, you need to login to acquire the token. You need to do this very infrequently after the first time. Check your token expiration date from your response.

api.login().then( function( result ) {
  // do something with token
  console.log( result.access_token );
});

All other functions

Next, all functions within this package return promises. That means that you can organize your code in the followind fashion:

api.loadToken( token ).then( api.getUserPreference ).then( function ( res ) {
  console.log( res );
}, function ( err ) {
  console.log( err );
});

In most cases, you will need to pass a parameter, so bind the function to correct context:

api.loadToken( token ).then(
  api.postUserMessage.bind(this, { body: 
                                   { recipient: "dchem",
                                     subject: "Yo DAWG",
                                     message: "I heard you like voat" } } )
).then( function ( res ) {
  console.log( res );
}, function ( err ) {
  console.log( err );
});

License

See LICENSE file.

Keywords

FAQs

Last updated on 18 Jun 2015

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc