adobe/stock-api-libjs

Name: stock-api-libjs

Owner: Adobe Systems Incorporated

Description: JavaScript implementation of the Stock APIs

Created: 2018-02-27 23:04:08.0

Updated: 2018-03-16 22:00:33.0

Pushed: 2018-03-16 22:00:32.0

Homepage:

Size: 202

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

Stock API libjs

Overview

This is a Javascript implementation of the various APIs provided by the Stock services.

Usage
AdobeStock
Instantiation Methods
SearchFilesIterator
Methods Example
t accessToken = 'fdkgnio4isoknzklnvw409jknvzksnvai3289r4209tjaornuivn34nivh3jt340fjvn9304jt';
t queryParams = {
le: 'en-US',
ch_parameters: {
rds: 'tree house',
mit: 10,
fset: 10,
lters_template_category_id: [
AdobeStock.SEARCH_PARAMS_TEMPLATE_CATEGORIES.PRINT,
AdobeStock.SEARCH_PARAMS_TEMPLATE_CATEGORIES.PHOTO,

lters_area_pixels: '0-2500',


t stock = new AdobeStock('Stock_Client_Api_key', 'Stock Client/1.0.0', AdobeStock.ENVIRONMENT.PROD);
t iterator = stock.searchFiles(accessToken,
                              queryParams,
                              null);
eturns with error
ator.previous()
  .then(() => {})
  .catch((error) => {
    console.error(error);
  });

eturns with success  
ator.next().then(() => {
t response = iterator.getResponse();
nsole.log(response.files.length);
nsole.log('total search files: ' + iterator.totalSearchFiles());
nsole.log('total search pages: ' + iterator.totalSearchPages());
nsole.log('current search page: ' + iterator.currentSearchPageIndex());

 still returns with error since we are on the first page
erator.previous()
      .then(() => {})
      .catch((error) => {
        console.error(error);
      });

erator.next().then(() => {
// now previous returns with success since we are on the second page
iterator.previous().then(() => {
  response = iterator.getResponse();
  console.log(response.files.length);

  // skip the searchFiles results to a particular search results page index
  iterator.skipTo(5).then(() => {
    response = iterator.getResponse();
    console.log(response.files.length);
  });
});
;

 you can create as many iterators as you want for different search queries
nst iterator2 = stock.searchFilesByKeywords(accessToken,
                                  'tree house',
                                  'en-US',
                                  null,
                                  null);

erator2.next().then(() => {
// make sure that you are using correct iterator in the promise resolve methods.
let response = iterator2.getResponse();
// let response = iterator.getResponse(); //will return the response from old iterator
console.log(response.files.length);
console.log('total search files: ' + iterator2.totalSearchFiles());
console.log('total search pages: ' + iterator2.totalSearchPages());
console.log('current search page: ' + iterator2.currentSearchPageIndex());
;

LicenseHistoryIterator
Methods Example
t accessToken = 'fdkgnio4isoknzklnvw409jknvzksnvai3289r4209tjaornuivn34nivh3jt340fjvn9304jt';
t queryParams = {
cale: 'en-US',
arch_parameters: {
limit: 10,
offset: 10,


t resultColumns = [
obeStock.LICENSE_HISTORY_RESULT_COLUMNS.THUMBNAIL_110_URL,

t stock = new AdobeStock('Stock_Client_Api_key', 'Stock Client/1.0.0', AdobeStock.ENVIRONMENT.PROD);
t iterator = stock.licenseHistory(accessToken,
                              queryParams,
                              resultColumns);
eturns with error
ator.previous()
  .then(() => {})
  .catch((error) => {
    console.error(error);
  });

eturns with success  
ator.next().then(() => {
t response = iterator.getResponse();
nsole.log(response.files.length);
nsole.log('total search files: ' + iterator.totalSearchFiles());
nsole.log('total search pages: ' + iterator.totalSearchPages());
nsole.log('current search page: ' + iterator.currentSearchPageIndex());

 still returns with error since we are on the first page
erator.previous()
      .then(() => {})
      .catch((error) => {
        console.error(error);
      });

erator.next().then(() => {
// now previous returns with success since we are on the second page
iterator.previous().then(() => {
  response = iterator.getResponse();
  console.log(response.files.length);

  // skip the licenseHistory results to a particular license history page index
  iterator.skipTo(5).then(() => {
    response = iterator.getResponse();
    console.log(response.files.length);
  });
});
;
Query Parameter Object

In order to simplify the passing of query parameter object to searchFiles methods, we have mapped the actual URL parameters of searchFiles api to simpler property names. User can use the below tabular mapping of URL parameters with Query Parameter Property names for creating query parameter object:

| URL Parameter | Query Parameter Property | Query Parameter Property Key | |———————–|————————–|——————————| | locale | locale | AdobeStock.QUERY_PARAMS_PROPS.LOCALE | | search_parameters[*] | search_parameters | AdobeStock.QUERY_PARAMS_PROPS.SEARCH_PARAMETERS | | similar_image | similar_image | AdobeStock.QUERY_PARAMS_PROPS.SIMILAR_IMAGE |

search_parameters property of query parameter is in itself an object and it stores the corresponding URL parameters as per the mapping mentioned below:

| URL Parameter | search_parameters Property | search_parameters Property Key | |——————————————————-|—————————-|——————————–| | search_parameters[words] | words | AdobeStock.SEARCH_PARAMS.WORDS | | search_parameters[limit] | limit | AdobeStock.SEARCH_PARAMS.LIMIT | | search_parameters[offset] | offset | AdobeStock.SEARCH_PARAMS.OFFSET| | search_parameters[order] | order | AdobeStock.SEARCH_PARAMS.ORDER | | search_parameters[creator_id] | creator_id | AdobeStock.SEARCH_PARAMS.CREATOR_ID | | search_parameters[media_id] | media_id | AdobeStock.SEARCH_PARAMS.MEDIA_ID | | search_parameters[model_id] | model_id | AdobeStock.SEARCH_PARAMS.MODEL_ID | | search_parameters[serie_id] | serie_id | AdobeStock.SEARCH_PARAMS.SERIE_ID | | search_parameters[gallery_id] | gallery_id | AdobeStock.SEARCH_PARAMS.GALLERY_ID | | search_parameters[similar] | similar | AdobeStock.SEARCH_PARAMS.SIMILAR | | search_parameters[similar_url] | similar_url | AdobeStock.SEARCH_PARAMS.SIMILAR_URL |
| search_parameters[similar_image] | similar_image | AdobeStock.SEARCH_PARAMS.SIMILAR_IMAGE | | search_parameters[category] | category | AdobeStock.SEARCH_PARAMS.CATEGORY | | search_parameters[thumbnail_size] | thumbnail_size | AdobeStock.SEARCH_PARAMS.THUMBNAIL_SIZE | | search_parameters[filters][area_pixels] | filters_area_pixels | AdobeStock.SEARCH_PARAMS.FILTERS_AREA_PIXELS | | search_parameters[filters][3d_type_id][] | filters_3d_type_id | AdobeStock.SEARCH_PARAMS.FILTERS_3D_TYPE_ID | | search_parameters[filters][template_type_id][] | filters_template_type_id | AdobeStock.SEARCH_PARAMS.FILTERS_TEMPLATE_TYPE_ID | | search_parameters[filters][template_category_id][] | filters_template_category_id | AdobeStock.SEARCH_PARAMS.FILTERS_TEMPLATE_CATEGORY_ID | | search_parameters[filters][has_releases] | filters_has_releases | AdobeStock.SEARCH_PARAMS.FILTERS_HAS_RELEASES | | search_parameters[filters][content_type:photo] | filters_content_type_photo | AdobeStock.SEARCH_PARAMS.FILTERS_CONTENT_TYPE_PHOTO | | search_parameters[filters][content_type:illustration] | filters_content_type_illustration | AdobeStock.SEARCH_PARAMS.FILTERS_CONTENT_TYPE_ILLUSTRATION | | search_parameters[filters][content_type:vector] | filters_content_type_vector | AdobeStock.SEARCH_PARAMS.FILTERS_CONTENT_TYPE_VECTOR | | search_parameters[filters][content_type:video] | filters_content_type_video | AdobeStock.SEARCH_PARAMS.FILTERS_CONTENT_TYPE.VIDEO | | search_parameters[filters][content_type:3d] | filters_content_type_3d | AdobeStock.SEARCH_PARAMS.FILTERS_CONTENT_TYPE_3D | | search_parameters[filters][content_type:all] | filters_content_type_all | AdobeStock.SEARCH_PARAMS.FILTERS_CONTENT_TYPE_ALL | | search_parameters[filters][offensive:2] | filters_offensive_2 | AdobeStock.SEARCH_PARAMS.FILTERS_OFFENSIVE_2 | | search_parameters[filters][isolated:on] | filters_isolated_on | AdobeStock.SEARCH_PARAMS.FILTERS_ISOLATED_ON | | search_parameters[filters][panoramic:on] | filters_panoramic_on | AdobeStock.SEARCH_PARAMS.FILTERS_PANORAMIC_ON | | search_parameters[filters][orientation] | filters_orientation | AdobeStock.SEARCH_PARAMS.FILTERS_ORIENTATION | | search_parameters[filters][age] | filters_age | AdobeStock.SEARCH_PARAMS.FILTERS_AGE | | search_parameters[filters][video_duration] | filters_video_duration | AdobeStock.SEARCH_PARAMS.FILTERS_VIDEO_DURATION | | search_parameters[filters][colors] | filters_colors | AdobeStock.SEARCH_PARAMS.FILTERS_COLORS | | search_parameters[filters][premium] | filters_premium | AdobeStock.SEARCH_PARAMS.FILTERS_PREMIUM |

Example:
t queryParams = {
cale: 'en-US',
arch_parameters: {
words: 'tree house',
media_id: 123324324,
filters_content_type_photo: 1,
filters_age: AdobeStock.SEARCH_PARAMS_AGE.TWO_YEAR,
filters_template_category_id: [
  AdobeStock.SEARCH_PARAMS_TEMPLATE_CATEGORIES.PHOTO,
  AdobeStock.SEARCH_PARAMS_TEMPLATE_CATEGORIES.MOBILE,
],
similar_image: 1,

milar_image: File,

or

t queryParams = {};
t qProps = AdobeStock.QUERY_PARAMS_PROPS;
yParams[qProps.LOCALE] = 'en-US';
yParams[qProps.SIMILAR_IMAGE] = File;

t searchParams = {};
t sProps = AdobeStock.SEARCH_PARAMS;
chParams[sProps.WORDS] = 'tree house';
chParams[sProps.MEDIA_ID] = 123324324;
chParams[sProps.FILTERS_CONTENT_TYPE_PHOTO] = 1;
chParams[sProps.FILTERS_AGE] = AdobeStock.SEARCH_PARAMS_AGE.TWO_YEAR;
chParams[sProps.FILTERS_TEMPLATE_TYPE_ID] = [
obeStock.SEARCH_PARAMS_TEMPLATE_CATEGORIES.PHOTO,
obeStock.SEARCH_PARAMS_TEMPLATE_CATEGORIES.MOBILE,


yParams[qProps.SEARCH_PARAMETERS] = searchParams;
Result Columns

The AdobeStock allows you to access the list of result columns which can be used to create result columns array. For e.g.

t resultColumns = [
obeStock.RESULT_COLUMNS.ID,
obeStock.RESULT_COLUMNS.TITLE,
obeStock.RESULT_COLUMNS.THUMBNAIL_URL,
obeStock.RESULT_COLUMNS.WIDTH,
obeStock.RESULT_COLUMNS.HEIGHT,
obeStock.RESULT_COLUMNS.CREATION_DATE,
obeStock.RESULT_COLUMNS.KEYWORDS,

License State

The AdobeStock defines various licensing state for the asset. They are accessible on AdobeStock object. For e.g.

t LICENSE_STATE_PARAMS = {
PTY: {
EMPTY_LICENSE: '',

AGE: {
STANDARD: 'standard',
STANDARD_M: 'standard_m',
EXTENDED: 'extended',

DEO: {
VIDEO_HD: 'video_hd',
VIDEO_4K: 'video_4k',

CTOR_ASSETS: {
STANDARD: 'standard',
EXTENDED: 'extended',

SETS_3D: {
STANDARD: 'standard',

MPLATES: {
STANDARD: 'standard',


Purchase State

The AdobeStock defines various user's purchase relationship to an asset. They are accessible on AdobeStock object. For e.g.

t PURCHASE_STATE_PARAMS = {
T_PURCHASED: 'not_purchased',
RCHASED: 'purchased',
NCELLED: 'cancelled',
T_POSSIBLE: 'not_possible',
ST_PURCHASED: 'just_purchased',
ERAGE: 'overage',

Install Dependencies
Running the Test Suite
Linting
Build

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.