Giter VIP home page Giter VIP logo

node-instapaper's Introduction

Instapaper API

Node.js client for the Instapaper API.

Work in progress!

Installation

$ npm i instapaper

Quick example

var Instapaper = require('instapaper');
var client     = Instapaper(CONSUMER_KEY, CONSUMER_SECRET);

client.setUserCredentials(USERNAME, PASSWORD);

// Load a list of bookmarks using promises...
client.bookmarks.list().then(function(bookmarks) {
  console.log('%j', bookmarks);
}).catch(function(err) {
  console.warn('oh noes', err);
});

// ...or regular callbacks
client.bookmarks.list(function(err, bookmarks) {
  if (err) return console.warn('oh noes', err);
  console.log('%j', bookmarks);
});

Authentication

The Instapaper API uses xAuth, which requires that you first register for API usage here. When your registration has been approved, you will receive a "consumer key" and "consumer secret", which you pass to the Instapaper constructor (see below).

You also need either:

  • a username and password belonging to the user on whose behalf you want to manage Instapaper;
  • or, an OAuth token and secret from a previous authentication round.

You should never store the username/password locally. Instead, after you've used them to get an OAuth token/secret pair, use those instead.

Usage:

Constructor

var client = Instapaper(CONSUMER_KEY : String, CONSUMER_SECRET : String[, OPTIONS : Object]);

OPTIONS is an optional object that may contain the following properties:

apiUrl   : String // Instapaper API URL prefix (default: 'https://www.instapaper.com/api/1')
logLevel : String // log level                 (default: 'info')

Authentication

Set user credentials

client.setUserCredentials(USERNAME : String, PASSWORD : String) : client

Set OAuth credentials

client.setOAuthCredentials(TOKEN : String, SECRET : String) : client

Authenticate

client.authenticate() : Promise

All regular API methods call this method implicitly. However, if you want to retrieve the OAuth credentials you can use this method to do so:

client.authenticate().then(function(oauth) {
  // { token : '...', secret : '...' }
});

Verify credentials

This can be used to verify that authenticating as the user was successful.

client.verifyCredentials() : Promise

Bookmarks management

Please refer to the API documentation for valid parameters and response formats.

client.bookmarks.list(PARAMS)           : Promise
client.bookmarks.getText(BOOKMARK_ID)   : Promise
client.bookmarks.delete(BOOKMARK_ID)    : Promise
client.bookmarks.star(BOOKMARK_ID)      : Promise
client.bookmarks.unstar(BOOKMARK_ID)    : Promise
client.bookmarks.archive(BOOKMARK_ID)   : Promise
client.bookmarks.unarchive(BOOKMARK_ID) : Promise

Folder management

TBD.

Terms of use

Please read the Instapaper API Terms of Use before using this API client.

AUTHOR

Robert Klep <[email protected]>

LICENCE

See LICENSE.md.

node-instapaper's People

Contributors

robertklep avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.