You can query cdnjs via our API as below
Without any query parameters it will return the name and main file URL of every library on cdnjs:
https://api.cdnjs.com/libraries
To search, use:
https://api.cdnjs.com/libraries?search=[query]
You can also "select" a certain library if you already know its name on CDNJS, e.g.
https://api.cdnjs.com/libraries/[name]
Without any query parameters it will return the whole meta data of the library, if you want to specify the info you want (recommended), use "fields" query:
https://api.cdnjs.com/libraries/jquery?fields=name,filename,version
All the usable fields is the same as the library's package.json on
CDNJS
(except auto-update config, we'll only return the auto-update type (currently npm or git
)
API will reture minified result by default, if you wanna have a human readable result, try
output=human
like so:
https://api.cdnjs.com/libraries?output=human
https://api.cdnjs.com/libraries?search=[query]?output=human
If you would like more data, use the fields parameter which takes comma-separated values:
https://api.cdnjs.com/libraries?search=[query]&fields;=version,description
To get a list of all files for that library, use the assets field:
https://api.cdnjs.com/libraries?search=[query]&fields;=assets
Other fields available are:
version
description
homepage
keywords
license
repository
autoupdate
author
assets
{"results":[{"name":"1140","latest":"https://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.min.css"},{"name":"1000hz-bootstrap-validator","latest":"https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.6/validator.min.js"},{"name":"10up-sanitize.css","latest":"https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/4.1.0/sanitize.min.css"},{"name":"16pixels","latest":"https://cdnjs.cloudflare.com/ajax/libs/16pixels/0.1.8/16pixels.min.css"},
{
"results": [
{
"name": "1140",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.min.css"
},
{
"name": "1000hz-bootstrap-validator",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/1000hz-bootstrap-validator/0.11.8/validator.min.js"
},
{
"name": "10up-sanitize.css",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/10up-sanitize.css/4.1.0/sanitize.min.css"
},
{
"name": "16pixels",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/16pixels/0.1.8/16pixels.min.css"
},
{"results":[{"name":"ractive","latest":"https://cdnjs.cloudflare.com/ajax/libs/ractive/0.8.5/ractive.min.js"},{"name":"ractive.js","latest":"https://cdnjs.cloudflare.com/ajax/libs/ractive.js/0.3.7/ractive.min.js"},{"name":"ractive-require","latest":"https://cdnjs.cloudflare.com/ajax/libs/ractive-require/0.6.12/ractive-require.min.js"}],"total":3}
{
"results": [
{
"name": "ractive",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/ractive/0.8.5/ractive.min.js"
},
{
"name": "ractive.js",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/ractive.js/0.3.7/ractive.min.js"
},
{
"name": "ractive-require",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/ractive-require/0.6.12/ractive-require.min.js"
}
],
"total": 3
}
Search with specific fields{"results":[{"name":"ractive","latest":"https://cdnjs.cloudflare.com/ajax/libs/ractive/0.8.5/ractive.min.js","version":"0.8.5","description":"Next-generation DOM manipulation"},{"name":"ractive.js","latest":"https://cdnjs.cloudflare.com/ajax/libs/ractive.js/0.3.7/ractive.min.js","version":"0.3.7","description":"Next-generation DOM manipulation"},{"name":"ractive-require","latest":"https://cdnjs.cloudflare.com/ajax/libs/ractive-require/0.6.12/ractive-require.min.js","version":"0.6.12","description":"Require Ractive views on demand in Package by Feature way"}],"total":3}
Search with specific fields Human Readable output{
"results": [
{
"name": "ractive",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/ractive/0.8.5/ractive.min.js",
"version": "0.8.5",
"description": "Next-generation DOM manipulation"
},
{
"name": "ractive.js",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/ractive.js/0.3.7/ractive.min.js",
"version": "0.3.7",
"description": "Next-generation DOM manipulation"
},
{
"name": "ractive-require",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/ractive-require/0.6.12/ractive-require.min.js",
"version": "0.6.12",
"description": "Require Ractive views on demand in Package by Feature way"
}
],
"total": 3
}
Specific Library Assets{"results":[{"name":"1140","latest":"https://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.min.css","assets":[{"version":"2.0","files":["1140.css","1140.min.css"]}]}],"total":1}
Specific Library Assets Human Readable output{
"results": [
{
"name": "1140",
"latest": "https://cdnjs.cloudflare.com/ajax/libs/1140/2.0/1140.min.css",
"assets": [
{
"version": "2.0",
"files": [
"1140.css",
"1140.min.css"
]
}
]
}
],
"total": 1
}