0.1.7 • Published 8 years ago

synq v0.1.7

Weekly downloads
3
License
MIT
Repository
github
Last release
8 years ago

Synq Node.js client library

Client library simplifying use of the SYNQ.fm API from a Node service

The library provides functions mirroring the endpoints in the api, and some simplifying functions.

It makes use of request-promise so all functions returns promises.

Get started

Install:

yarn add synq or npm install --save synq

Require or import:

import Synq from 'synq' or let Synq = require('synq').default;

Usage

Basic examples for all endpoints

import Synq from 'synq'

// Init the library by setting the url and api key
const api = new Synq(process.env.SYNQ_API_KEY, 'https://api.synq.fm/v1/');

// Create a new video object
api.video.create([userdata: Object])
  .then((videoObject) => {
    console.log('Video object created successfully', videoObject)
  })
  .catch((error) => {
    console.log('Error: ', error.statusCode);
    console.log(error.message);
  });

// Get a video object
api.video.details(videoId: string)
  .then(etc... )

// Query video objects by equality to a single key value pair in the metadata
api.video.querySimple(key: string, value: string)
  .then(etc...)

// Query videoobjects by metadata fields by providing filtering code
// ex: 'if (video.views > 3000) { return video }' returns all videos where views > 300
api.video.query(filter: string)
  .then(etc...)

// Update the metadata of a video object by providing code that handles the update
// eks: 'video.userdata.baz = "bar"'
api.video.update(source: string, videoId: string)
  .then(etc...)

// Get upload parameters to Amazon S3.
api.video.upload(videoId: string)
  .then(etc...)

// Get embeddable uploader
api.video.uploader(videoId: string)
  .then(etc...)

// Get streaming details
api.video.stream(videoId: string)
  .then(etc... )

Error handling

If an error happens the promise will reject with an error object.

The library forwards the error from the request library, read their docs for more details

Test

Integration tests are included for all api methods.

You need to set enviroment variable SYNQ_API_KEY=yourAPIKey to run them.

Then do: yarn test

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

9 years ago

0.1.4

9 years ago

0.1.3

9 years ago

0.1.2

9 years ago

0.1.1

9 years ago

0.1.0

9 years ago