cdnjs provides a simple API to allow anyone to quickly query the libraries we have on the CDN.

We provide two main endpoints, the libraries endpoint which allows anyone to search through the full set of libraries we offer, and the libraries/:library endpoint which allows for detailed data to be ascertained for a specific library.

Browsing all libraries on cdnjs

The /libraries endpoint will return a JSON object with three top-level properties.

This API endpoint can also be used to search cdnjs for libraries, by making use of the optional search URL query parameter.

The cache lifetime on this endpoint is six hours.

Query Parameters

Parameter Type Required Description
search string optional

The value to use when searching the libraries index on cdnjs.

Libraries will not be ranked by search relevance when they are returned, they will be ranked using the same ranking as when no search query is provided.

This ranking is done by Algolia and is primarily based on the number of stars each library's associated GitHub repo has.

fields comma-separated string optional

Provide a comma-separated string of fields to return in each library object from the cdnjs Algolia index.

name and latest will always be present in every object. Any field requested that does not exist will be included in each object with a null value.

Currently, the following fields (case-sensitive) are published in the Algolia index for each library and can be requested via this parameter: filename, description, version, keywords, alternativeNames, fileType, github, objectID, license, homepage, repository, author, originalName, sri.

The available fields are based on the SearchEntry structure in our tools repo.

search_fields comma-separated string optional

Provide a comma-separated string of fields to be considered when searching for a given search query parameter.

Not all fields are supported for this, any unsupported fields given will be silently ignored. Currently, the following fields (case-sensitive) are supported: name, alternativeNames, github.​repo, description, keywords, filename, repositories.​url, github.​user, maintainers.​name.

The supported fields are controlled by our Algolia settings and are mirrored in the API server libraries route logic.

limit integer optional

Limit the number of library objects that are returned in the results array.

This value will be reflected in the total top-level property, but the available property will return the full number with no limit applied.

output string optional

Use the output value human to receive the JSON results in pretty print format, presented on a HTML page.

JSON Response

Property Type Description
results array<object> 

This property will contain an object for every library that cdnjs has available.

results[].name string 

This will be the full name of the library, as stored on cdnjs.

results[].latest string 

This will be the URL of the default file on the latest version of the library.

It is important to note that this URL is based on the latest version number of the library and the default file name configured, there is no validation in place to ensure that this URL will actually serve a valid asset.

results[].filename optional  string 

The will be the name of the default file for the library.

There is no validation that this file actually exists in each version of the library.

results[].description optional  string 

The description of the library if it has been provided in the cdnjs package JSON file.

results[].version optional  string 

The latest version of the library that is available on cdnjs.

results[].keywords optional  nullable  array<string> 

An array of keywords provided in the cdnjs package JSON for the library.

results[].alternativeNames optional  array<string> 

An array of other names that might be used for the library. These cannot be substituted for the actual library name when navigating the cdnjs API and website.

results[].fileType optional  string 

The file type (extension) for the default file defined for the library in the cdnjs package JSON.

results[].github optional  nullable  object 

Some meta data from the relevant GitHub repository for the library, if available and configured in the cdnjs package JSON for the library.

results[].github.user optional  string 

The username or organisation name for the repository on GitHub.

results[].github.repo optional  string 

The name of the repository on GitHub.

The full repository name can be constructed in the form user/repo.

results[].github.stargazers_count optional  integer 

The number of stars that the repository has on GitHub.

results[].github.forks optional  integer 

The number of forks the repository currently has (at time of indexing) on GitHub.

results[].github.subscribers_count optional  integer 

The number of users on GitHub who are watching the repository.

results[].objectID optional  string 

The ID used internally within Algolia to track this entry, this will be the name of the library as seen on cdnjs.

results[].license optional  string 

The license defined for the library on cdnjs, as a string. If the library has a custom license, it may not be shown here.

results[].homepage optional  string 

A link to the homepage of the package, if one is defined in the cdnjs package JSON file. Normally, this is either the package repository or the package website.

results[].repository optional  nullable  object 

The repository for the library, if known, in standard repository format.

results[].repository.type optional  string 

The type of repository for the library, normally git.

results[].repository.url optional  string 

The url for repository associated with the library, if provided in the library's cdnjs package JSON file.

results[].author optional  string 

The attributed author for the library, as defined in the cdnjs package JSON file for this library.

results[].originalName optional  string 

If the library on cdnjs was every renamed, this value will contain the original name for this library. If it hasn't been renamed, this value will match the current name.

results[].sri optional  string 

The SRI hash value for the file provided in the latest property, if it exists and is valid (i.e. if the SRI hash could be calculated for it).

total integer 

The total number of libraries returned in the request.

available integer 

If a limit query parameter is given, this will be the total number of libraries available if no limit is given. If no limit parameter is given, this will match the total property.

This endpoint is directly powered by our Algolia index, the same one that is used on this website for the search box at the top and on the Libraries page .

Example Requests

https://api.cdnjs.com/libraries

{"results":[{"name":"vue","latest":"https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js"},{"name":"react","latest":"https://cdnjs.cloudflare.com/ajax/libs/react/16.13.1/umd/react.production.min.js"},{"name":"react-dom","latest":"https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.13.1/umd/react-dom.production.min.js"},{"name":"react-is","latest":"https://cdnjs.cloudflare.com/ajax/libs/react-is/16.13.1/umd/react-is.production.min.js"},{"name":"twitter-bootstrap","latest":"https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.4.0/js/bootstrap.min.js"},{"name":"d3","latest":"https://cdnjs.cloudflare.com/ajax/libs/d3/5.16.0/d3.min.js"},{"name":"axios","latest":"https://cdnjs.cloudflare.com/ajax/libs/axios/0.19.2/axios.min.js"},{"name":"animate.css","latest":"https://cdnjs.cloudflare.com/ajax/libs/animate.css/4.0.0/animate.min.css"},{"name":"font-awesome","latest":"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.13.0/css/all.min.css"}, "..."],"total":3606,"available":3606}

Example response has been trimmed to remove items in the results array.

https://api.cdnjs.com/libraries?search=jquery

{"results":[{"name":"jquery","latest":"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js"},{"name":"jquery-compat","latest":"https://cdnjs.cloudflare.com/ajax/libs/jquery-compat/3.0.0-alpha1/jquery.min.js"},{"name":"blueimp-file-upload","latest":"https://cdnjs.cloudflare.com/ajax/libs/blueimp-file-upload/10.23.0/js/jquery.fileupload.min.js"},{"name":"fullPage.js","latest":"https://cdnjs.cloudflare.com/ajax/libs/fullPage.js/3.0.8/fullpage.min.css"},{"name":"select2","latest":"https://cdnjs.cloudflare.com/ajax/libs/select2/4.0.12/js/select2.min.js"},{"name":"chosen","latest":"https://cdnjs.cloudflare.com/ajax/libs/chosen/1.8.7/chosen.jquery.min.js"},{"name":"cheerio","latest":"https://cdnjs.cloudflare.com/ajax/libs/cheerio/1.0.0-rc.3/index.js"},{"name":"Sortable","latest":"https://cdnjs.cloudflare.com/ajax/libs/Sortable/1.10.1/Sortable.min.js"}, "..."],"total":865,"available":865}

Example response has been trimmed to remove items in the results array.

https://api.cdnjs.com/libraries?search=vue&fields=filename,description,version,github&limit=3

{"results":[{"name":"vue","latest":"https://cdnjs.cloudflare.com/ajax/libs/vue/2.6.11/vue.min.js","filename":"vue.min.js","description":"Simple, Fast & Composable MVVM for building interactive interfaces","version":"2.6.11","github":{"user":"vuejs","repo":"vue","stargazers_count":163564,"forks":24743,"subscribers_count":6145}},{"name":"element-ui","latest":"https://cdnjs.cloudflare.com/ajax/libs/element-ui/2.13.1/index.js","filename":"index.js","description":"A Component Library for Vue.js.","version":"2.13.1","github":{"user":"ElemeFE","repo":"element","stargazers_count":45141,"forks":10399,"subscribers_count":1378}},{"name":"vuetify","latest":"https://cdnjs.cloudflare.com/ajax/libs/vuetify/2.3.0-beta.4/vuetify.min.js","filename":"vuetify.min.js","description":"Vue.js 2 Semantic Component Framework","version":"2.3.0-beta.4","github":{"user":"vuetifyjs","repo":"vuetify","stargazers_count":25230,"forks":4186,"subscribers_count":575}}],"total":3,"available":53}

Getting a specific library on cdnjs

Accessing assets for all versions of a library using this endpoint is deprecated. The assets property now only contains a single entry for the latest version. To access the assets of any version, use the /libraries/:library/:version endpoint.

See cdnjs/cdnjs issue #14140 for more information.

The /libraries/:library endpoint allows for data on a specific library to be requested and will return a JSON object with all library data properties by default.

The cache lifetime on this endpoint is six hours.

Query Parameters

Parameter Type Required Description
fields comma-separated string optional

Provide a comma-separated string of fields to return in the library object.

output string optional

Use the output value human to receive the JSON results in pretty print format, presented on a HTML page.

JSON Response

Property Type Description
name string 

This will be the full name of the library, as stored on cdnjs.

latest string 

This will be the URL of the default file on the latest version of the library.

It is important to note that this URL is based on the latest version number of the library and the default file name configured, there is no validation in place to ensure that this URL will actually serve a valid asset.

sri string 

The SRI hash value for the file provided in the latest property, if it exists and is valid (i.e. if the SRI hash could be calculated for it).

filename string 

This will be the name of the default file for the library. If not defined in the package's JSON file, this will be an empty string

There is no validation that this file actually exists in each version of the library.

version string 

The latest version of the library that is available on cdnjs.

description string 

The description of the library if it has been provided in the cdnjs package JSON file.

homepage optional  string 

A link to the homepage of the package, if one is defined in the cdnjs package JSON file. Normally, this is either the package repository or the package website.

If the library has no defined homepage, this property will be omitted (unless requested via fields explicitly, then it will be null).

keywords nullable  array<string> 

An array of keywords provided in the cdnjs package JSON for the library.

repository nullable  object 

The repository for the library, if known, in standard repository format.

repository.type string 

The type of repository for the library, normally git.

repository.url string 

The url for repository associated with the library, if provided in the library's cdnjs package JSON file.

license optional  string 

The license defined for the library on cdnjs, as a string. If the library has a custom license, it may not be shown here.

If the library has no defined licenses in its cdnjs package JSON file, this property may be omitted (if explicitly requested via fields, it will be null).

author nullable  string 

The attributed author for the library, as defined in the cdnjs package JSON file for this library.

autoupdate optional  object 

The auto-update configuration for the library, from the library's package JSON file on cdnjs.

If the library has no auto-update configuration, this property will not be present (unless explicitly requested with fields, then it will be null).

autoupdate.type optional  string 

The source type of auto-update begin used for the library, either git or npm.

This may be replaced with the source property in some responses.

autoupdate.source optional  string 

This property is the same as type but may be present in some responses instead of type.

autoupdate.target string 

The target for the auto-update configuration. If git, this should be a valid git URL, if npm this will be a package name from the NPM package repository.

versions array<string> 

An array containing all the versions of the library available on cdnjs.

These may not be valid semver.

assets array<object> 

An array containing an object for the latest version of the library on cdnjs. The array is empty if the library has no known versions.

Older versions of the library are no longer included in this array. See deprecation notice.

assets[].version string 

The version identifier for this version of the library on cdnjs.

This may not be valid semver.

assets[].files array<string> 

The files available for this version of the library on the cdnjs CDN.

This array of files is filtered by our CDN whitelist, so all these files will be available for use on our CDN.

assets[].rawFiles array<string> 

All the files that cdnjs has for this version of the library, irrespective of if they will be available on the CDN.

This array of files ignores the whitelist filter, which means some files may not be available on the CDN if their extensions aren't whitelisted.

assets[].sri object  map<string, string> 

This object will contain a key for each file that cdnjs could calculate an SRI hash for, with the value being the SRI hash.

Example Requests

https://api.cdnjs.com/libraries/vue?fields=name,author,description,filename,sri,version,repository,autoupdate

{"name":"vue","author":"Evan You <[email protected]>","description":"Simple, Fast & Composable MVVM for building interactive interfaces","filename":"vue.min.js","sri":null,"version":"3.2.37","repository":{"type":"git","url":"https://github.com/vuejs/vue.git"},"autoupdate":{"source":"npm","target":"vue","fileMap":[{"basePath":"dist","files":["**/*.+(js|map)"]}]}}

https://api.cdnjs.com/libraries/react?fields=name,description

{"name":"react","description":"React is a JavaScript library for building user interfaces."}

https://api.cdnjs.com/libraries/jquery?fields=assets,versions

{"assets":[{"version":"3.6.0","files":["jquery.js","jquery.min.js","jquery.min.map","jquery.slim.js","jquery.slim.min.js","jquery.slim.min.map"],"rawFiles":["jquery.js","jquery.min.js","jquery.min.map","jquery.slim.js","jquery.slim.min.js","jquery.slim.min.map"],"sri":{"jquery.js":"sha512-n/4gHW3atM3QqRcbCn6ewmpxcLAHGaDjpEBu4xZd47N0W2oQ+6q7oc3PXstrJYXcbNU1OHdQ1T7pAP+gi5Yu8g==","jquery.min.js":"sha512-894YE6QWD5I59HgZOGReFYm4dnWc1Qt5NtvYSaNcOP+u1T9qYdvdihz0PPSiiqn/+/3e7Jo4EaG7TubfWGUrMQ==","jquery.slim.js":"sha512-HNbo1d4BaJjXh+/e6q4enTyezg5wiXvY3p/9Vzb20NIvkJghZxhzaXeffbdJuuZSxFhJP87ORPadwmU9aN3wSA==","jquery.slim.min.js":"sha512-6ORWJX/LrnSjBzwefdNUyLCMTIsGoNP6NftMy2UAm1JBm6PRZCO1d7OHBStWpVFZLO+RerTvqX/Z9mBFfCJZ4A=="}}],"versions":["1.10.0","1.10.1","1.10.2","1.11.0","1.11.0-beta3","1.11.0-rc1","1.11.1","1.11.1-beta1","1.11.1-rc1","1.11.1-rc2","1.11.2","1.11.3","1.12.0","1.12.1","1.12.2","1.12.3","1.12.4","1.2.3","1.2.6","1.3.0","1.3.1","1.3.2","1.4.0","1.4.1","1.4.2","1.4.3","1.4.4","1.5.1","1.6.1","1.6.2","1.6.3","1.6.4","1.7","1.7.1","1.7.2","1.8.0","1.8.1","1.8.2","1.8.3","1.9.0","1.9.1","2.0.0","2.0.1","2.0.2","2.0.3","2.1.0","2.1.0-beta2","2.1.0-beta3","2.1.0-rc1","2.1.1","2.1.1-beta1","2.1.1-rc1","2.1.1-rc2","2.1.2","2.1.3","2.1.4","2.2.0","2.2.1","2.2.2","2.2.3","2.2.4","3.0.0","3.0.0-alpha1","3.0.0-beta1","3.0.0-rc1","3.1.0","3.1.1","3.2.0","3.2.1","3.3.0","3.3.1","3.4.0","3.4.1","3.5.0","3.5.1","3.6.0"]}

Getting a specific version for a library on cdnjs

The /libraries/:library/:version endpoint returns a JSON object with details specific to a requested version of a library on cdnjs.

The cache lifetime on this endpoint is 355 days, identical to the CDN. The response is also marked as immutable, as a version on cdnjs will never change once published.

cdnjs only allows access to specific versions of a library, and these are considered immutable. Access to tags for a library, such as latest, is not supported as these have a mutable definition, which would go against what cdnjs aims to provide with long-life caching on responses and SRI hashes.

Query Parameters

Parameter Type Required Description
fields comma-separated string optional

Provide a comma-separated string of fields to return in the library version object.

output string optional

Use the output value human to receive the JSON results in pretty print format, presented on a HTML page.

JSON Response

Property Type Description
name string 

This will be the full name of the library, as stored on cdnjs.

version string 

The version of the library that has been requested. This should match the version requested in the URL.

files array<string> 

The files available for this version of the library on the cdnjs CDN.

This array of files is filtered by our CDN whitelist, so all these files will be available for use on our CDN.

rawFiles array<string> 

All the files that cdnjs has for this version of the library, irrespective of if they will be available on the CDN.

This array of files ignores the whitelist filter, which means some files may not be available on the CDN if their extensions aren't whitelisted.

sri object  map<string, string> 

This object will contain a key for each file that cdnjs could calculate an SRI hash for, with the value being the SRI hash.

Example Requests

https://api.cdnjs.com/libraries/jquery/3.5.1

{"name":"jquery","version":"3.5.1","rawFiles":["jquery.js","jquery.min.js","jquery.min.map","jquery.slim.js","jquery.slim.min.js","jquery.slim.min.map"],"files":["jquery.js","jquery.min.js","jquery.min.map","jquery.slim.js","jquery.slim.min.js","jquery.slim.min.map"],"sri":{"jquery.js":"sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=","jquery.min.js":"sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=","jquery.slim.js":"sha256-DrT5NfxfbHvMHux31Lkhxg42LY6of8TaYyK50jnxRnM=","jquery.slim.min.js":"sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs="}}

https://api.cdnjs.com/libraries/vue/2.6.11?fields=files,sri

{"files":["vue.common.dev.js","vue.common.js","vue.common.prod.js","vue.esm.browser.js","vue.esm.browser.min.js","vue.esm.js","vue.js","vue.min.js","vue.runtime.common.dev.js","vue.runtime.common.js","vue.runtime.common.prod.js","vue.runtime.esm.js","vue.runtime.js","vue.runtime.min.js"],"sri":{"vue.common.dev.js":"sha256-soI/D3XnqcarOMK229d8GWs8P+gYViEsbWBeMaRoSPk=","vue.common.js":"sha256-G3CZay/nob7tG4ai5FI/O2sYakyatJ+0uknDnG3PSOc=","vue.common.prod.js":"sha256-L5CcYf/nJAyrA48AanDrEMdYitv4IL63aLL2geeCbEg=","vue.esm.browser.js":"sha256-HZGk4wNx/Sr9icBC5/ICwETaEvUvlcfCFwV0A4FgcU4=","vue.esm.browser.min.js":"sha256-2vv0EVENz4Azm6KkclYqEr1Hlk1GTTle9oFlZzBmdg0=","vue.esm.js":"sha256-ZbWf3bBKhQRGjg6NxSziPDQQrdPVIEp3yTYKQuMDBNk=","vue.js":"sha256-NSuqgY2hCZJUN6hDMFfdxvkexI7+iLxXQbL540RQ/c4=","vue.min.js":"sha256-ngFW3UnAN0Tnm76mDuu7uUtYEcG3G5H1+zioJw3t+68=","vue.runtime.common.dev.js":"sha256-K1I+V5ATCKkhmeLuhXPLi6MJ6baIMq63AdKfLr1to5o=","vue.runtime.common.js":"sha256-iPf9+Ogi9Q0ERtzOtUPfBttEZT7SGb3l/9LAldqDJmQ=","vue.runtime.common.prod.js":"sha256-Tj24teFUOrMRvvqrKP0Td42X/kbj/SJfgjTenZuIjJ8=","vue.runtime.esm.js":"sha256-R/wILGaOjQG2P8U21mBPH0uRyRIfF4xXW49y0buxBmo=","vue.runtime.js":"sha256-ry9SZACrXbOKzkD0/qM/0Z+ELi24EcrhwFgKF2cTuUQ=","vue.runtime.min.js":"sha256-vT4XcKWLfaGor0IJgp3nAOzlVh3B29yLJ7paM+bYgao="}}

Fetch details about the cdnjs file extension whitelist

The /whitelist endpoint returns a JSON object containing a list of extensions permitted on the CDN as well as categories for those extensions.

The cache lifetime on this endpoint is 6 hours.

Query Parameters

Parameter Type Required Description
fields comma-separated string optional

Provide a comma-separated string of fields to return from the available whitelist data.

output string optional

Use the output value human to receive the JSON results in pretty print format, presented on a HTML page.

JSON Response

Property Type Description
extensions array<string> 

The full list of file extensions that are whitelisted on the CDN, allowing files with these extensions to be available.

categories object  map<string, string> 

An object that maps each whitelisted extension to a category, used for sorting files on the cdnjs website.

Example Requests

https://api.cdnjs.com/whitelist

{"extensions":["js","ts","wasm","map","swf","json","css","scss","png","gif","jpg","jpeg","svg","webp","cur","ttf","eot","woff","woff2","otf","aac","mp3","ogg","lang","hpb"],"categories":{"js":"JavaScript","ts":"TypeScript","wasm":"WebAssembly","map":"Source Maps","swf":"Flash","json":"JSON","css":"Styling","scss":"Styling","png":"Images","gif":"Images","jpg":"Images","jpeg":"Images","svg":"Images","webp":"Images","cur":"Images","ttf":"Fonts","eot":"Fonts","woff":"Fonts","woff2":"Fonts","otf":"Fonts","aac":"Audio","mp3":"Audio","ogg":"Audio","lang":"Other","hpb":"Other"}}

Fetch basic statistics for cdnjs

The /stats endpoint returns a JSON object containing a set of statistics relating to cdnjs.

The cache lifetime on this endpoint is 6 hours.

Query Parameters

Parameter Type Required Description
fields comma-separated string optional

Provide a comma-separated string of fields to return from the available whitelist data.

output string optional

Use the output value human to receive the JSON results in pretty print format, presented on a HTML page.

JSON Response

Property Type Description
libraries integer 

The total number of libraries available on cdnjs and on the API.

Example Requests

https://api.cdnjs.com/stats

{"libraries":3909}

Error responses from the cdnjs API

All errors generated by using the cdnjs API will return with a unified structure for easy detection & processing. They will return a JSON object containing the error status code as well as a message explaining the error. The HTTP response code will also reflect the error.

404 error responses will have a 1 hour cache lifetime, all other errors (5xx etc.) have no cache lifetime set.

JSON Response

Property Type Description
error boolean 

This will always be set to true to indicate that an error has occurred.

status integer 

The status code for the error, which should be identical to the HTTP response status code.

message string 

A message explaining what error has occurred.

Example Requests

https://api.cdnjs.com/libraries/this-library-doesnt-exist

{"error":true,"status":404,"message":"Library not found"}

https://api.cdnjs.com/this-route-doesnt-exist

{"error":true,"status":404,"message":"Endpoint not found"}