0.14.1 • Published 6 years ago

ooyala-api v0.14.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

NPM version Build Status Coverage Status Dependency Status

ooyala-api

Ooyala API client library and CLI for Node.js

Install

NPM

API

const OoyalaApi = require('ooyala-api');

const api = new OoyalaApi('Your Ooyala API Key', 'Your Ooyala API Secret', {concurrency: 6});
const embedCode = 'Content ID';

// GET
api.get(`/v2/assets/${embedCode}`)
.then((body) => {
  // JSON object
})
.catch((err) => {
  // Error response
});

// GET (with params + pagination)
api.get('/v2/assets', {where: `labels+INCLUDES+'Music'`}, {recursive: true})
.then((items) => {
  // All items in an array (recursive calls will be done internally)
})
.catch((err) => {
  // Error response
});

// POST
api.post('/v2/assets', {}, {
  name: `test ${Date()}`,
  asset_type: 'remote_asset',
  is_live_stream: true,
  stream_urls: {
    'flash': FLASH_URL,
    'iphone': IPHONE_URL
  }
}).then((body) => {});

// DELETE
api.delete(`/v2/assets/${embedCode}`).then((body) => {});

options

APIOption NameTypeDefaultMeaning
constructorsubdomainString"api"Will be used to construct the destination server's host name. (default=api.ooyala.com)
constructorsecureBooleanfalseIf true, the library sends https request
constructorexpirationTimeInteger86400TTL of the API call in seconds
constructorconcurrencyInteger5Limits the number of concurrent API calls. The valid range is 1~10
constructoraccountSecretString""Account Token API's secret key
getrecursiveBooleanfalseIf true, the library calls API recursively as long as next_page is specified in the response
get, post, put, delete, patchheadersObjectundefinedIf the object contains HTTP headers, the key-value pairs are used for the request.
get, post, put, delete, patchrequestURLStringundefinedIf defined, the url is just used. No params are added internally.
get, post, put, delete, patchaccountIdStringundefinedIf defined, Account Token API will be called with the specified accountId before the main API call. And then its return value (account_token) will be used for the main API call.
get, post, put, delete, patchsubdomainString(the value specified at constructor)Overrides the value specified at constructor.
get, post, put, delete, patchsecureBoolean(the value specified at constructor)Overrides the value specified at constructor.

CLI

Please put config file(s) in your work directory.

 $ mkdir config
 $ vi config/default.json
 {
   "api": {
     "key":        "Your Ooyala API Key",
     "secret":     "Your Ooyala API Secret"
   }
 }
Usage:
    oo [options] command [parameters]

Options:
  -h, --help    Print help
  -v, --version Print version

Commands:
  token           Generates Ooyala player token (OPT) request URL.
  sign            Generates a signature based on given params.
  upload          Uploads file(s).
  remote          Creates a remote asset
  source          Downloads source file to stdout

Syntax:
  oo token embed-code(s) [accountId]
  oo sign url [method body]
  oo upload local-file-path(s) [title chunkSize profile]
  oo remote asset-name [dash hls hds]
  oo source embed-code [info]

Example:
  oo -v
  oo token embed_code
  oo token embed_code1 embed_code2
  oo token embed_code --expiration 604800
  oo token embed_code --accountId david1203
  oo sign /hoge?foo=bar
  oo sign /hoge?foo=bar --body '{"data": {"comment": "This is JSON"}}'
  oo sign /hoge?foo=bar --body '{"data": {"comment": "This is JSON"}}' --method PATCH
  oo upload ./path/to/file --title "My video"
  oo upload ./path/to/files/*.mp4 --title "My videos" --chunkSize 1024 --profile abc
  oo upload ./path/to/files --title "My VR 360 videos" --profile xyz --vrType monoscopic
  oo remote "My remote asset" --dash http://x.jp/a.mpd --hls http://x.jp/a.m3u8 --hds http://x.jp/a.f4m
  oo source embed_code1 --info
  oo source embed_code1 > ./path/to/file
  oo source embed_code1 --resume ./path/to/file

Parameters:
  expiration    TTL of the signature in seconds (this param works with every command that requires signing)
  accountId     Viewer's login id (default = undefined)
  method        (GET | POST | PUT | DELETE | PATCH) default = GET
  body          Body string (default = '')
  title         Title of the video (default = {file name} if multiple files are specified, the title is suffixed by '- part n')
  chunkSize     Byte size of each chunk (default = 204800)
  profile       Profile id used for encoding
  vrType        monoscopic or stereoscopic(side-by-side)
  dash          Remote asset URL for MPEG-DASH
  hls           Remote asset URL for HTTP Live Streaming
  hds           Remote asset URL for HTTP Dynamic Streaming
  info          If specified the output will be source_file_info
  resume        An existing file to which the data will be appended
0.14.1

6 years ago

0.14.0

6 years ago

0.13.3

6 years ago

0.13.2

7 years ago

0.13.1

7 years ago

0.13.0

7 years ago

0.12.1

7 years ago

0.12.0

7 years ago

0.11.1

7 years ago

0.11.0

7 years ago

0.10.0

7 years ago

0.9.1

7 years ago

0.9.0

7 years ago

0.8.0

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.6.5

7 years ago

0.6.4

7 years ago

0.6.3

7 years ago

0.6.2

7 years ago

0.6.1

7 years ago

0.6.0

7 years ago

0.5.2

8 years ago

0.5.1

8 years ago

0.5.0

8 years ago

0.4.5

8 years ago

0.4.4

8 years ago

0.4.3

8 years ago

0.4.2

8 years ago

0.4.1

8 years ago

0.4.0

8 years ago

0.3.1

8 years ago

0.2.4

8 years ago

0.2.3

8 years ago

0.2.2

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago

0.0.3

8 years ago

0.0.2

8 years ago

0.0.1

8 years ago