pa-snappa-api-client-node

0.4.3 • Public • Published

Introduction

Welcome to the node.js client for the SNAPPA API by PA (Press Association).

Installation

To utilise the SNAPPA API client for node.js install the npm module.

npm install pa-snappa-api-client

Usage

After the installation of the npm package you can start making calls to the SNAPPA API. Initially you need to instantiate the client, using your API key:

const SnappaClient = require('pa-snappa-api-client');
 
const client = new SnappaClient({ baseUrl: 'http://snappa.api.press.net/v1-beta', apikey: '<YOUR API KEY' });

Once instantiated you can make requests against the Feeds, Assets and Tags resources provided by the SNAPPA API as follows:

Resources

Feeds

The Feeds resource provides access to feeds.

List Feeds

client
  .feeds()
  .get(function(err, res, feeds) {
    console.log(err);
    console.log(res);
    console.log(feeds);
  });

Get Feed Items

client
  .feeds()
  .id('firehose')
  .sortProperty('modified')
  .limit(50)
  .offset(1)
  .get(function(err, res, feed) {
    console.log(err);
    console.log(res);
    console.log(feed);
  });

Assets

The Assets resource provides access to assets.

List Assets

client
  .assets()
  .query('space')
  .get(function(err, res, assets) {
    console.log(err);
    console.log(res);
    console.log(assets);
  });

Get Asset

client
  .assets()
  .id('abc-123')
  .get(function(err, res, asset) {
    console.log(err);
    console.log(res);
    console.log(feed);
  });

Tags

The Tags resource provides access to tags.

List Tags

client
  .tags()
  .query('space')
  .get(function(err, res, tags) {
    console.log(err);
    console.log(res);
    console.log(tags);
  });

Readme

Keywords

none

Package Sidebar

Install

npm i pa-snappa-api-client-node

Weekly Downloads

1

Version

0.4.3

License

ISC

Last publish

Collaborators

  • stevenr