Socket
Book a DemoInstallSign in
Socket

jwplatform-api

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jwplatform-api

Simple wrapper around the jwPlatform API

latest
Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
36
300%
Maintainers
1
Weekly downloads
 
Created
Source

jsPlatform API

This is a simple wrapper for NodeJS around the jsPlatform API to make api calls easier.

Installation

npm install jwplatform-api

Usage

Creating a new jwPlatform API object:

var jwPlatform = require('jwplatform-api');

//initialize with your key and secret
var api = new jwPlatform({
    key: '...',
    secret: '...'
});

//initialize with custom logger
var logger = {
    debug: function() {},
    error: function() {}
};
var api = new jwPlatform({ ... }, logger);

//initialize with no logging
var api = new jwPlatform({ ... }, function() {});

Make arbitrary queries:

api.get('v1/videos/show', { video_key: 'some_key' }, null, function(err, result) {
    //result will be a JSON object
});

var template = {
    name: 'Test template',
    format_key: 'ogg',
    default: 'none'
};

api.post('v1/templates/create', null, template, function(err, result) {
    //...
});

There are a few shortcuts for common api calls:

Generating an upload URL

api.getUploadUrl('v1', function(err, result) {
    //sample result:
    /*
    { uploadUrl: 'http://upload.jwplatform.com/v1/videos/upload?api_format=json&key=...&token=...',
      progressUrl: 'http://upload.jwplatform.com/progress?token=...&key...' }
     */
});

Getting information about a video (conversions/list wrapper)

api.getVideoData('v1', '<your video key>', function(err, result) {
    //sample result:
    /*
    { completed: 3,
         total: 3,
         videos:
          [ { status: 'ready',
              key: '...',
              width: 640,
              height: 360,
              size: 2165175,
              duration: 32.48,
              url: 'http://content.jwplatform.com/originals/....webm' },
            { status: 'ready',
              key: '...',
              width: 320,
              height: 180,
              size: 1114818,
              duration: 32.5,
              url: 'http://content.jwplatform.com/videos/...-....mp4' },
            { status: 'ready',
              key: '...',
              width: 480,
              height: 270,
              size: 1594358,
              duration: 32.5,
              url: 'http://content.jwplatform.com/videos/...-....mp4' } ],
         ready: true }
     */
});

Template stuff

var template = {
    name: 'the name',
    format_key: 'ogg',
    default: 'none'
};
api.createTemplate('v1', template, function(err, result) { });

var fields = {
    template_key: '...',
    name: 'the new name'
};
api.updateTemplate('v1', fields, function(err, result) { });

api.getTemplates('v1', function(err, result) { });

Keywords

jwplatform

FAQs

Package last updated on 10 Oct 2014

Did you know?

Socket

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