0.13.0 • Published 8 years ago

shutterstock v0.13.0

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

Shutterstock Build Status

This is a Node.js Shutterstock API client.

Usage

Install

$ npm install shutterstock --save

Example

var shutterstock = require('shutterstock');

var api = shutterstock.v2({
  clientId: 'a134a44b2220a831d511',
  clientSecret: '0498a3442cf2ad2d11efbda32a32fa26a20d229c',
});

api.image.get('108559295', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Documentation

All callbacks have the following signature function(err, data, res).

  • err (Error, optional): set if there was an error, otherwise falsy
  • data (Object, optional): response data if any, otherwise undefined
  • res (http.IncomingMessage, optional): HTTP response object with additional body property. This might not exist when err is set. The body property can be a decoded object, string, or Buffer.

This is a client for interacting with API v2.

Options

  • clientId (String): OAuth2 client ID
  • clientSecret (String): OAuth2 client secret
  • accessToken (String, optional): OAuth2 access token
  • timeout (Number, default: 30000): number of milliseconds before request is aborted

Usage

var shutterstock = require('shutterstock');

var v2 = shutterstock.v2({
  clientId: 'client-id',
  clientSecret: 'client-secret',
});

Get details for multiple audio tracks.

Options - Documentation

  • id (String[]): track IDs
  • view (String, optional): render view

Usage

v2.audio.list(['113011', '15326'], function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get details for a specified track.

Options - Documentation

  • id (String): track ID
  • view (String, optional): render view

Usage

v2.audio.get('113011', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Search tracks.

Options - Documentation

  • query (String, optional): query string
  • page (Number, default: 1): page to return
  • per_page (Number, default: 20): number of results to return per page
  • sort (String, default: popular): sort results

And many more, see official documentation for more details.

Usage

v2.audio.search('beat', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Search tracks.

Options - Documentation

  • id (String): contributor ID

Usage

v2.contributor.get('164782', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get all image categories.

Documentation

Usage

v2.image.categories(function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get details for multiple images.

Options - Documentation

  • id (String[]): image IDs
  • view (String, optional): render view

Usage

v2.image.list(['108559295', '143051491'], function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get details for a specified image.

Options - Documentation

  • id (String): image ID
  • view (String, optional): render view

Usage

v2.image.get('108559295', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Return recommendations for specified images.

Options - Documentation

  • id (String[]): image IDs
  • max_items (Number, default: 20): number of results to return

And more, see official documentation for more details.

Usage

v2.image.recommendations(['108559295', '143051491'], function(err, data) {
  if (err) throw err;

  console.log(data);
});

Search images.

Options - Documentation

  • query (String, optional): query string
  • page (Number, default: 1): page to return
  • per_page (Number, default: 20): number of results to return per page
  • sort (String, default: popular): sort results

And many more, see official documentation for more details.

Usage

v2.image.search('donkey', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get similar images.

Options - Documentation

  • id (String, optional): image ID
  • page (Number, default: 1): page to return
  • per_page (Number, default: 20): number of results to return per page
  • sort (String, default: popular): sort results

Usage

v2.image.similar('108559295', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Download an image.

Options - Documentation

  • id (String, optional): image ID
  • size (String, optional): image size to download

Usage

v2.image.download('108559295', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get details for multiple videos.

Options - Documentation

  • id (String[]): video IDs
  • view (String, optional): render view

Usage

v2.video.list(['108559295', '143051491'], function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get details for a specified video.

Options - Documentation

  • id (String): video ID
  • view (String, optional): render view

Usage

v2.video.get('5869544', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Search videos.

Options - Documentation

  • query (String, optional): query string
  • page (Number, default: 1): page to return
  • per_page (Number, default: 20): number of results to return per page
  • sort (String, default: popular): sort results

And many more, see official documentation for more details.

Usage

v2.video.search('donkey', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get similar videos.

Options - Documentation

  • id (String, optional): video ID
  • page (Number, default: 1): page to return
  • per_page (Number, default: 20): number of results to return per page
  • sort (String, default: popular): sort results

Usage

v2.video.similar('4535879', function(err, data) {
  if (err) throw err;

  console.log(data);
});

This is a client for interacting with API v1.

Options

  • username (String): API username (not to be confused with customer username)
  • password (String): API password (key)
  • timeout (Number, default: 30000): number of milliseconds before request is aborted

Usage

var shutterstock = require('shutterstock');

var v1 = shutterstock.v1({
  username: 'api-username',
  password: 'api-password',
});

Echo back specified options, used to check API connection and credentials.

Options - Documentation

  • key (String): value

Usage

v1.image.echo({ hello: 'world' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Search images.

Options - Documentation

  • searchterm (String): search query
  • sort_method (String, default: popular): sort results
  • page_number (Number, default: 0): page to return
  • results_per_page (Number, default: 150): number of results to return per page
  • submitter_id (Number, optional): filter results by contributor ID

And many more, see official documentation for more details.

Usage

v1.image.search('donkey', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get details for a specified image.

Options - Documentation

  • image_id (Number): image ID

Usage

v1.image.get(108559295, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get images similar to a specified image.

Options - Documentation

  • image_id (Number): image ID

Usage

v1.image.similar(108559295, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get all image categories.

Documentation

Usage

v1.image.categories(function(err, data) {
  if (err) throw err;

  console.log(data);
});

License image.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • subscription_id (Number): photo subscription ID
  • image_id (Number): image ID
  • size (String): image size
  • format (String): image format

And more, see official documentation for more details.

Usage

var opts = {
  image_id: 108559295,
  subscription_id: 123,
  size: 'huge',
  format: 'jpg',
};

v1.image.download(opts, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Authenticate as a user.

Options - Documentation

  • email (String): user's email, required if username not specified
  • username (String): user's username, required if email not specified
  • password (String): user's password

Usage

v1.customer.auth({ username: 'john', password: 'secret' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get user information.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • username (String): user's username

Usage

v1.customer.get({ username: 'john' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Create new customer account.

Options - Documentation

  • email (String): new user's email address
  • username (String): new user's username
  • password (String): new user's password

Usage

v1.customer.register({ email: 'john@example.org', username: 'john', password: 'secret' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get user's image downloads and the subscriptions under which they were downloaded.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • username (String): user's username
  • image_id (Number, optional): get downloads for specific image
  • license (String, optional): filter results by license
  • page_number (Number, default: 0): page to return
  • page_size (Number, default: 40): number of results to return per page
  • sort_by (String, optional): sort results
  • sort_order (String, default: desc): sort order

Usage

v1.customer.images({ username: 'john' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get customer subscriptions.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • username (String): user's username

Usage

v1.customer.subscriptions({ username: 'john' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get customer lightboxes.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • username (String): user's username
  • exclude_empty (Boolean, default: false): filter empty lightboxes
  • exclude_images (Boolean, default: false): only return lightbox metadata

Usage

v1.lightbox.list({ username: 'john' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get contents of lightbox.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • lightbox_id (Number): lightbox ID
  • verification_code (String, optional): access lightbox without auth_token, get from lightbox.publicUrl

Usage

v1.lightbox.get({ lightbox_id: 123 }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Return public URL for lightbox.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • lightbox_id (Number): lightbox ID

Usage

v1.lightbox.publicUrl({ lightbox_id: 123 }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Create new lightbox.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • username (String): user's username
  • lightbox_name (String): new lightbox name

Usage

v1.lightbox.create({ username: 'john', lightbox_name: 'Animals' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Update lightbox.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • lightbox_id (Number): lightbox ID
  • lightbox_name (String): updated lightbox name

Usage

v1.lightbox.update({ lightbox_id: 123, lightbox_name: 'Animals' }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Delete lightbox.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • lightbox_id (Number): lightbox ID

Usage

v1.lightbox.destroy({ lightbox_id: 123 }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Add image to lightbox.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • lightbox_id (Number): lightbox ID
  • image_id (Number): image ID to add to lightbox

Usage

v1.lightbox.add({ lightbox_id: 123, image_id: 108559295 }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Remove image from lightbox.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • lightbox_id (Number): lightbox ID
  • image_id (Number): image ID to remove from lightbox

Usage

v1.lightbox.remove({ lightbox_id: 123, image_id: 108559295 }, function(err, data) {
  if (err) throw err;

  console.log(data);
});

Search videos.

Options - Documentation

  • searchterm (String): search query
  • sort_method (String, default: popular): sort results
  • page_number (Number, default: 0): page to return
  • results_per_page (Number, default: 150): number of results to return per page
  • submitter_id (Number, optional): filter results by contributor ID

Usage

v1.video.search('donkey', function(err, data) {
  if (err) throw err;

  console.log(data);
});

Get details for a specified video.

Options - Documentation

  • video_id (Number): video ID

Usage

v1.video.get(6061547, function(err, data) {
  if (err) throw err;

  console.log(data);
});

License video.

Options - Documentation

  • auth_token (String): authentication token, get from customer.auth
  • subscription_id (Number): footage subscription ID
  • video_id (Number): video ID
  • size (String): video size

And more, see official documentation for more details.

Usage

var opts = {
  video_id: 5869544,
  subscription_id: 123,
  size: 'hd',
};

v1.video.download(opts, function(err, data) {
  if (err) throw err;

  console.log(data);
});

License

This work is licensed under the MIT License (see the LICENSE file).

0.13.0

8 years ago

0.12.0

9 years ago

0.11.0

9 years ago

0.10.0

9 years ago

0.9.1

10 years ago

0.9.0

10 years ago

0.8.0

10 years ago

0.7.0

10 years ago

0.6.0

10 years ago

0.5.0

10 years ago

0.4.0

10 years ago

0.3.0

10 years ago

0.2.0

10 years ago

0.0.0

10 years ago