skroutz.js
An npm module for using the skroutz.gr API with nodeJS
Installation
npm install skroutz
Quick start
Once you have an Identifier
and a Secret
you are ready to create a client.
var Client = ; var client = 'client_id': 'Identifier' 'client_secret': 'Secret';
After that, using the client to access the API is as simple as passing the methods you want and calling fetch()
.
client; client;
Available resources
clientclientclientclientclientclientclientclient
Usage
- Accessing a specific API route is very simple. The URL is translated from all the method calls on the client object. For example if you want to access
GET /categories/root
you simply usejs client.Category().root()
. The fetch method must be called with a callback function argument in the end of the API call like this:
;
The final query will look like this:
client;
- Accessing routes that use dynamic URIs like
GET /categories/:id/parent
is as simple as usingjs client.Category(id).parent()
and then fetching. - Accessing routes with parameters at the end like:
GET http://api.skroutz.gr/categories/40/skus?manufacturer_ids[]=28&manufacturer_ids[]=2
will require the use of the methodjs .params({manufacturer_ids[]: 28, manufacturer_ids[]: 2})
like this:
client
and then fetching.
Conditional Requests
Most responses return Last-Modified and ETag headers. You can use the values of these headers to make subsequent requests to those resources. This headers are accessed by using js response.cache[`etag`]
and js response.cache[`last-modified`]
. You can only use one of them for every request by using either the methodjs.cacheEtag("the etag string")
or js .cacheModified("Current date")
before the fetch method. If no new data is available this small json will be present on the response:
js { cached: true }