1.4.0 • Published 9 years ago
punchcard-request v1.4.0
Punchcard Request

Installation
npm i punchcard-request --saveUsage
Punchcard Request can either be used to make a single request or make a collection of requests to a Punchcard API. A single request is an object with and endpoint specified, with optional configuration and API options. To make multiple requests, collect all desired single requests in to an array. Single requests return as an object, collections of requests are returned as an array.
const request = require('punchcard-request');
const items = [
{
get: 'all',
},
{
get: 'types',
},
];
request(items).then(results => {
console.log(results); // Array of paginated content and paginated content types available
});Options
Endpoints
All endpoints are options of the get parameter. Some endpoints require an additional parameter for clarity. These parameters are required.
all- All content availabletypes- All content types availabletype- All content of a specific content type. Requires an additionaltypeparameter for the content typeone- A single piece of content. Requires additionaltypeandidproperties for the content type and content ID
Configuration
punchcard- The URL to the root of the Punchcard install. Can also be set by setting aPUNCHCARDenvironment variable.
API Options
sort- API attribute to sort on. Can be one ofid,type,type-slug,key,key-slug. Defaults tokeydirsort_dir- Sort direction, can be one ofascordesc. Defaults toascpage- The page to request (for pagination). Defaults to1, starts at 1limitper_page- The max number of items to return per page (for pagination). Defaults to30key- Contentkeythat you would like to filter the request for. Only works withallandtypeendpointsslugkey_slug- Contentkey_slugthat you would like to filter the request for. Only works withallandtypeendpoints