0.1.12 • Published 8 years ago

client-api v0.1.12

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

Client API

Donate

Rest like client api calls

Install

> npm install client-api --save

dependencies:

Use

var Api = require('client-api');

Create

var api = new Api(settings);

Settings

var settings = {
    token: '32digits',
    version: 'v1',
    baseName: '/api/',
    dataType: 'json'
}
nametypedescription
tokenStringserver authorization with token
versionStringapi version
baseNameStringbase url without domain.tld
dataTypeStringdata format

Calls

api(method, path, params, data, callback);
nametypedescription
methodStringget, post, put, delete, path
pathStringapi version
paramsObjectset maximal video amount
dataObjectoption on get and delete
callbackFunctionrecieving function

GET

api('get', '/category/article', {}, callback);

GET with Params

each :{name} will replace by key value from params object

var params = {
    publisher: 'times',
    category: 'book',
    id: 5
};

api('get', '/:publisher/:category/:id', params, callback);

Result http://domain.tld./api/v1/times/book/5

PUT / POST

var data = {
    name: 'newName'
};

api('put', 'category/article/:id', {
    id: inputId
}, data, callback);

DELETE

api('delete', 'category/article/:id', {
    id: inputId
}, callback);
0.1.12

8 years ago

0.1.11

8 years ago

0.1.10

8 years ago

0.1.9

8 years ago

0.1.8

8 years ago

0.1.7

8 years ago

0.1.6

8 years ago

0.1.5

8 years ago

0.1.3

8 years ago

0.0.15

9 years ago