npm

Need private packages and team management tools?Check out npm Orgs. »

buffer-node

1.0.4 • Public • Published

buffer-node

Build Status Code Climate

buffer-node is a Node.js API Client for Buffer

Installation

$ npm install buffer-node

Usage

Buffer-node offers an easy to use wrapper for the Buffer API.

Example:

var bufferAPI = require('buffer-node'),
  api = bufferAPI('{{user access token}}')
 
api.user.get().then(
  function(response) {
    // handle success
    console.log(response)
  },
  function(err) {
    // handle error
    console.log(err)
  }
)

Authentication

Buffer uses OAuth 2.0 for authorization. It is recommended to use a library such as Passport to authorize and retrieve an access token for the user.

Client creation

When requiring the buffer-node module, a factory function for the API client will be exposed. Simply pass an access token and the ready to use client will be returned.

var bufferAPI = require('buffer-node'),
  api = bufferAPI('{{user access token}}')

Requests

API requests always return a promise using the promise module. You should then use one of the supplied methods to handle successful calls and errors.

API functions

The API client completely covers the available Buffer API endpoints. Some methods can take optional parameters as an object. The keys and values correspond to the parameter specified in the API documentation.

When passing dates, the API client will automatically convert JavaScript Date instances to the right format.

User

Retrieve a single Buffer user account.

api.user.get()

Profiles

Retrieve the social media profiles associated with the current user account.

api.profiles.get()

Retrieve a single social media profile.

api.profile('<profile ID>').get()

Schedules

Retrieve schedules associated with a social media profile.

api.profile('<profile ID>').schedules.get()

Update schedules.

  • schedules array of schedules [{days: ['mon', 'fri'], times: ['08:00', '15:00']}]
api.profile('<profile ID>').schedules.update(schedules)

Updates

Retrieve pending updates for a social media profile.

  • options page, count, since, utc
api.profile('<profile ID>').updates.pending(options)

Retrieve sent updates for a social media profile.

  • options page, count, since, utc
api.profile('<profile ID>').updates.sent(options)

Retrieve a single update.

api.update('<update ID>').get()

Retrieve social media interaction for a single update.

  • event type of event
  • options count, page
api.update('<update ID>').interactions(event, options)

Reorder updates for a single social media profile.

  • order Array of update IDs
  • options offset, utc
api.profile('<profile ID>').updates.reorder(order, options)

Shuffle updates for a single social media profile.

  • options count, utc
api.profile('<profile ID>').updates.shuffle(options)

Create a new update.

  • text Update text
  • profileIds Array of profile IDs
  • options shorten, now, top, media, attachment, scheduled_at
api.updates.create(text, profileIds, options)

Modify an existing update.

  • text Update text
  • options now, media, utc, scheduled_at
api.update('<update ID>').update(text, options)

Immediately share an existing update.

api.update('<update ID>').share()

Delete an existing update.

api.update('<update ID>').destroy()

Move an existing update to the top of the Buffer queue.

api.update('<update ID>').moveToTop()

Links

Get number of shares for a link on Buffer.

  • url URL of the link
api.links.shares(url)

Info

Get configuration Buffer is using for its social media profiles.

api.info.configuration()

install

npm i buffer-node

Downloadsweekly downloads

144

version

1.0.4

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
  • avatar
Report a vulnerability