Перейти к файлу
ScottDowne 7da07d0285 Merge pull request #13 from mjschranz/async-parallel
Make search functionality run parallel for each service.
2015-04-14 14:10:51 -04:00
lib Make search functionality run parallel for each service. 2015-04-14 14:06:11 -04:00
.gitignore More complete demo 2013-08-12 13:18:01 -04:00
.travis.yml Add grunt linting to project 2013-08-29 15:10:13 -04:00
Gruntfile.js Major refactor, step 1 2013-09-17 11:34:26 -04:00
LICENSE Some initial structure 2013-08-08 12:07:03 -04:00
README.md Bug 950868 - Add functionality to search all services at once 2014-07-02 16:51:45 -04:00
index.js Bug 950868 - Add functionality to search all services at once 2014-07-02 16:51:45 -04:00
package.json 0.1.32 2014-08-13 11:17:54 -04:00

README.md

Webmaker MediaSync

MediaSync is a Node.js serverside NPM module designed to make searching for media from popular Web services easy with a universal API.

Initialization

The initialization of the module as very few parameters currently. They are as follows:

App Instance: A reference to your application's Express/Connect instance. This is used to attach the searching route to your application options - An object with the following properties:

  • serviceKeys - required - An object containing API keys for each service you plan to use.
  • limit - Used to specify the amount of results returned in a query. Defaults to 30.
  • cacheExpiry - Used to specify how long searches should be cached, in seconds. Defaults to 1800 seconds.

Example:

var mediasync = require( "webmaker-mediasync" );

mediasync( expressApp, {
  serviceKeys: {
    soundcloud: "d2idm12domodo12mdo12mdo2d12d",
    flickr: "d2di3mdi3di23md23idm",
    gihpy: "21d12d21d2d12d12d"
  }
});

Supported Services

Currently we support query based searching with the following services: YouTube, SoundCloud, Giphy and Flickr.

NOTE: YouTube does not currently require an API Key to be given to use it.

Usage

When initialized, the application will add one endpoint to your application to be used to make searches.

/api/webmaker/search/{SERVICE}?{QUERYSTRING_PARAMETERS}

SERVICE - Expects a value matching one of the following:

  • YouTube, SoundCloud, Giphy, All and Flickr. These can be any case, we lowercase this value before evaluating.
    • In the case of All, every supported service will have the provided query used against all supported services.

QUERYSTRING_PARAMETERS - These are used to specify more specific values, such as:

  • q - The search query that you are performing. Must be a URL safe (encoded) value.
  • page - Used to specify the page of results you want. A query may have 400 total results, but you will only ever recieve an amount of results matching what's specified in limit on initialization. Increase this value to get the next set of results.

Example Requests

  • /api/webmaker/search/YouTube?page=1&q=kittens
  • /api/webmaker/search/YouTube?page=3&q=cute%20kittens
  • /api/webmaker/search/YouTube?page=10&q=%22cute%20kittens%22

Responses

Responses are JSON.

Example success responses:

{
  status: "okay",
  currentPage: 3,
  results: [
    // Objects containing data
  ],
  total: 235
}

Example failure responses:

{
  status: "failure",
  reason: "[webmaker-mediasync]: Retrieving data for YouTube failed",
  error: {} // Some sort of object. For example, it could be from the service's API.
}