Skip to content
This repository was archived by the owner on Sep 10, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apiServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment thread
MattIPv4 marked this conversation as resolved.
};
algoliaIndex.search(req.query.search, searchParams, function(error, content) {
if (error) {
Expand Down
8 changes: 8 additions & 0 deletions templates/api.html
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ <h3>
CDNJS
</a>(except auto-update config, we'll only return the auto-update type (currently <code>npm or git</code>)
<br><br>
The API will return the maximum results by default (1000), but you can limit these with the "hitsPerPage" query
<br><br>
<code>https://api.cdnjs.com/libraries?search=[query]&hitsPerPage=10</code>
<br><br>
If you are using the "hitsPerPage" query, you can also use "page" to paginate (defaulting at 0)
<br><br>
<code>https://api.cdnjs.com/libraries?search=[query]&hitsPerPage=10&page=2</code>
<br><br>
API will return minified result by default, if you wanna have a human readable result, try
<code>output=human</code>
like so:
Expand Down