diff --git a/apiServer.js b/apiServer.js index 690d4c7249..ef4502645d 100755 --- a/apiServer.js +++ b/apiServer.js @@ -86,7 +86,8 @@ app.get('/libraries', function(req, res) { if (req.query.search) { var searchParams = { typoTolerance: 'min', // only keep the minimum typos - hitsPerPage: 1000 // maximum + page: req.query.page || 0, // default + hitsPerPage: req.query.hitsPerPage || 1000 // maximum }; algoliaIndex.search(req.query.search, searchParams, function(error, content) { if (error) { diff --git a/templates/api.html b/templates/api.html index b1507d52dc..99b900420b 100644 --- a/templates/api.html +++ b/templates/api.html @@ -40,6 +40,14 @@

CDNJS (except auto-update config, we'll only return the auto-update type (currently npm or git)

+ The API will return the maximum results by default (1000), but you can limit these with the "hitsPerPage" query +

+ https://api.cdnjs.com/libraries?search=[query]&hitsPerPage=10 +

+ If you are using the "hitsPerPage" query, you can also use "page" to paginate (defaulting at 0) +

+ https://api.cdnjs.com/libraries?search=[query]&hitsPerPage=10&page=2 +

API will return minified result by default, if you wanna have a human readable result, try output=human like so: