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

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.

assets array<object> 

An array containing an object for each version of the library that cdnjs has available.

assets[].version string 

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

This may, or 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.

versions array<string> 

An array containing all the versions from assets without the files.

tutorials array<object> 

An array that houses all tutorials that cdnjs has for this library, from the cdnjs/tutorials GitHub repository.

Alongside the properties listed here, there may be other optional properties available based on the metadata available in each source tutorial file.

tutorials[].id string 

The slug/identifier for the tutorial, based on the filename of the tutorial in cdnjs/tutorials.

This is the id that should be used when accessing the /libraries/:library/tutorials/:tutorial API endpoint.

tutorials[].modified string 

The timestamp of when the tutorial was last modified, in ISO 8601 format.

This is based on the last commit that touched the tutorial in cdnjs/tutorials.

tutorials[].name string 

The title/name for the tutorial.

tutorials[].content string 

The raw markdown content for the tutorial.

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":"sha256-ngFW3UnAN0Tnm76mDuu7uUtYEcG3G5H1+zioJw3t+68=","version":"2.6.11","repository":{"type":"git","url":"https://github.com/vuejs/vue.git"},"autoupdate":{"source":"npm","target":"vue"}}

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

{"name":"react","description":"React is a JavaScript library for building user interfaces.","tutorials":[{"id":"universal-react-apps","modified":"2017-09-05T17:31:26.000Z","author":{"name":"Ahmed Bouchefra","email":"[email protected]","description":"Web developer, technical writer and entrepreneur","homepage":"https://www.techiediaries.com","twitter":"techiediaries"},"description":"This tutorial will cover how to use React and Next.js to build a simple universal web app.","homepage":"https://www.techiediaries.com","keywords":["react","nextjs","universal"],"library-tags":["react","nextjs"],"name":"Building Universal Server Rendered Apps with React and Next.js 3.0","repository":"https://github.com/techiediaries","content":"\n## Introduction\n\nNext.js is a framework for quickly building universal (also called Isomorphic) server-rendered web apps with\nReact. In this tutorial you will learn essential concepts of server-rendered React apps by creating a demo app with Next.js.\n\nBuilding apps with Next.js is simple. You just create a <em>pages</em> directory and place React components in it.\nNext.js will take care of everything else.\n\nThis tutorial was originally published in [techiediaries](https://www.techiediaries.com/universal-react-apps-nextjs/)\n\nNow let's get started\n\nFirst we need to install the required tools:\n\n## Installing Next.js 2.0\n\nYou can install Next.js 2.0 via npm with:\n\n    npm install --save next react react-dom\n\n## Installing Next.js 3.0\n\nNext.js 3.0 is still in beta, you can also install it via npm with:\n\n    npm install [email protected] react react-dom --save\n\n## Adding NPM Scripts to package.json\n\nBuilding apps with Next.js is a matter of using three commands:\n\n    next\n    next build\n    next start\n\nSo lets add NPM scripts to trigger these commands:\n\n  \"scripts\": {\n    \"dev\": \"next\",\n    \"build\": \"next build\",\n    \"start\": \"next start\"\n  },\n\n## Adding Pages\n\nTo create pages you first need to create a pages directory:\n\n    mkdir pages\n\n### Adding the Home Page\n\nCreate an index.js file inside pages folder and put this content in it:\n\n    import Link from 'next/link'\n    export default () => (\n    <div>\n                <Link href='/'><a>Home</a></Link> -\n                <Link href='/about'><a>About Me</a></Link> -\n                <Link href='/contact'><a>Contact</a></Link>\n                <br></br>\n                <p>This is the home page</p>\n\n    </div>\n    )\n\n### Adding the About Page\n\nNext create an about.js file inside pages folder then put the following content:\n\n    import Link from 'next/link'\n    export default () => (\n    <div>\n                <Link href='/'><a>Home</a></Link> -\n                <Link href='/about'><a>About Me</a></Link> -\n                <Link href='/contact'><a>Contact</a></Link>\n                <br></br>\n                <p>This is about page</p>\n    </div>\n    )\n\n### Adding the Contact Page\n\nAdd contact.js file inside pages folder then put the following:\n\n    import Link from 'next/link'\n    export default () => (\n    <div>\n                <Link href='/'><a>Home</a></Link> -\n                <Link href='/about'><a>About Me</a></Link> -\n                <Link href='/contact'><a>Contact</a></Link>\n                <br></br>\n                <p>This is the contact page</p>\n\n    </div>\n    )\n\nNow you can launch next with:\n\n    npm run dev\n\nYour app will be available from [http://localhost:3000](http://localhost:3000).\n\nAs you can see the names of files inside pages directory become the routes except for / which points to index.js\n\n## Conclusion\n\nUniversal apps become very popular in these days and thanks to React and Next.js you can build them in a matter\nof a few commands.\n\nThanks for reading!\n"}]}

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

{"assets":[{"version":"3.5.1","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":"sha256-QWo7LDvxbWT2tbbQ97B53yJnYU3WhH/C8ycbRAkjPDc=","jquery.min.js":"sha256-9/aliU8dGd2tb6OSsuzixeV4y/faTqgFtohetphbbj0=","jquery.slim.js":"sha256-DrT5NfxfbHvMHux31Lkhxg42LY6of8TaYyK50jnxRnM=","jquery.slim.min.js":"sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs="}},{"version":"3.5.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":"sha256-r/AaFHrszJtwpe+tHyNi/XCfMxYpbsRg2Uqn0x3s2zc=","jquery.min.js":"sha256-xNzN2a4ltkB44Mc/Jz3pT4iU1cmeR0FkXs4pru/JxaQ=","jquery.slim.js":"sha256-sCexhaKpAfuqulKjtSY7V9H7QT0TCN90H+Y5NlmqOUE=","jquery.slim.min.js":"sha256-MlusDLJIP1GRgLrOflUQtshyP0TwT/RHXsI1wWGnQhs="}}, "..."],"versions":["3.5.1","3.5.0","3.4.1","3.4.0","3.3.1","3.3.0","3.2.1","3.2.0","3.1.1","3.1.0","3.0.0","3.0.0-rc1","3.0.0-beta1","3.0.0-alpha1","2.2.4","2.2.3","2.2.2","2.2.1","2.2.0","2.1.4","2.1.3","2.1.2","2.1.1","2.1.1-rc2","2.1.1-rc1","2.1.1-beta1","2.1.0","2.1.0-rc1","2.1.0-beta3","2.1.0-beta2","2.0.3","2.0.2","2.0.1","2.0.0","1.12.4","1.12.3","1.12.2","1.12.1","1.12.0","1.11.3","1.11.2","1.11.1","1.11.1-rc2","1.11.1-rc1","1.11.1-beta1","1.11.0","1.11.0-rc1","1.11.0-beta3","1.10.2","1.10.1","1.10.0","1.9.1","1.9.0","1.8.3","1.8.2","1.8.1","1.8.0","1.7.2","1.7.1","1.6.4","1.6.3","1.6.2","1.6.1","1.5.1","1.4.4","1.4.3","1.4.2","1.4.1","1.4.0","1.3.2","1.3.1","1.3.0","1.2.6","1.2.3","1.7"]}

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

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.

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="}}

Listing all tutorials for a library on cdnjs

The /libraries/:library/tutorials endpoint returns a JSON array containing all the user-submitted tutorials relating to this library on cdnjs. This is a mirror of the tutorials property returned from the main library endpoint.

The cache lifetime on this endpoint is 24 hours.

Alongside the properties listed here, there may be other optional properties available based on the metadata available in each source tutorial file.

Query Parameters

Parameter Type Required Description
fields comma-separated string optional

Provide a comma-separated string of fields to return for each tutorial object in the array.

The id property will always be present in every object to allow for identification of each tutorial in the array.

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
[].id string 

The slug/identifier for the tutorial, based on the filename of the tutorial in cdnjs/tutorials.

This is the id that should be used when accessing the /libraries/:library/tutorials/:tutorial API endpoint.

[].modified string 

The timestamp of when the tutorial was last modified, in ISO 8601 format.

This is based on the last commit that touched the tutorial in cdnjs/tutorials.

[].created string 

The timestamp of when the tutorial was first published, in ISO 8601 format.

This is based on the first commit where the tutorial was added in cdnjs/tutorials.

[].name string 

The title/name for the tutorial.

[].content string 

The raw markdown content for the tutorial.

Example Requests

https://api.cdnjs.com/libraries/vue/tutorials

[{"id":"wtf-is-vuex","modified":"2017-05-29T04:18:13.000Z","author":{"name":"Anthony","email":"[email protected]","description":"Web developer, author and online course instructor with Vue.js Developers","homepage":"http://vuejsdevelopers.com","twitter":"https://twitter.com/vuejsdevelopers"},"description":"Vuex is one of the most useful tools in the Vue.js ecosystem, but it can be very confusing at first. I've written this primer on Vuex to give you the background that I wish I'd had.","homepage":"http://vuejsdevelopers.com","keywords":["vue.js","vuex"],"library-tags":["vue.js","vuex"],"name":"WTF is Vuex? A Beginner's Guide To Vue's Application Data Store","repository":"https://github.com/vuejsdevelopers","content":"Vuex. Is it pronounced “vewks”, or “veweks”? Or maybe it’s meant to be “vew”, pronounced with a French-style silent “x”?\n\nMy trouble with understanding Vuex only began with the name.\n\nBeing an eager Vue developer I’d heard enough about Vuex to suspect that it must be an important part of the Vue ecosystem, even if I didn’t know what it actually was.\n\nI eventually had enough of wondering, so I went to the documentation with plans of a brief skim through; just enough to get the idea.\n\nTo my chagrin I was greeted with unfamiliar terms like “state management pattern”, “global singleton” and “source of truth”. These terms may make sense to anyone already familiar with the concept, but for me they didn’t gel at all.\n\nThe one thing I did get, though, was that Vuex had something to do with Flux and Redux. I didn’t know what those were either, but I figured it may help if I investigated them first.\n\nAfter a bit of research and persistence the concepts behind the jargon finally started to materialise in my mind. I was getting it. I went back to the Vuex documentation and it finally hit me…Vuex is freaking awesome!\n\nI’m still not quite sure how to pronounce it, but Vuex has become an essential piece in my Vue.js toolbelt. I think it’s totally worth your time to check it out too, so I’ve written this primer on Vuex to give you the background that I wish I’d had.\n\nNote: This article was originally posted [here on the Vue.js Developers blog](http://vuejsdevelopers.com/2017/05/15/vue-js-what-is-vuex/?jsdojo_id=cjs_wfv) on 2017/05/15 ..."}]

Example response has been trimmed to remove text from tutorial content.

https://api.cdnjs.com/libraries/backbone.js/tutorials?fields=name,modified

[{"id":"cross-domain-sessions","name":"Cross-domain Backbone.js with sessions using CORS","modified":"2017-09-05T17:41:17.000Z"},{"id":"infinite-scrolling","name":"Lightweight Infinite Scrolling using Twitter API","modified":"2017-09-05T17:41:17.000Z"},{"id":"nodejs-restify-mongodb-mongoose","name":"Simple example - Node.js, Restify, MongoDb and Mongoose ","modified":"2017-09-05T17:41:17.000Z"},{"id":"organizing-backbone-using-modules","name":"Organizing your application using Modules (require.js)","modified":"2017-09-05T17:41:17.000Z"},{"id":"real-time-backbone-with-pubnub","name":"Real-Time Backbone With PubNub","modified":"2018-07-28T08:54:41.000Z"},{"id":"seo-for-single-page-apps","name":"SEO for single page apps","modified":"2017-09-05T17:41:17.000Z"},{"id":"what-is-a-collection","name":"What is a collection?","modified":"2017-09-05T17:41:17.000Z"},{"id":"what-is-a-model","name":"What is a model?","modified":"2017-09-05T17:41:17.000Z"},{"id":"what-is-a-router","name":"What is a router?","modified":"2017-09-05T17:41:17.000Z"},{"id":"what-is-a-view","name":"What is a view?","modified":"2017-09-05T17:41:17.000Z"},{"id":"why-would-you-use-backbone","name":"Why do you need Backbone.js?","modified":"2017-09-05T17:41:17.000Z"}]

Getting a specific tutorial for a cdnjs library

The /libraries/:library/tutorials/:tutorial endpoint returns a JSON object containing metadata and the content of a specified user-submitted tutorial relating to the specified library hosted on cdnjs.

The cache lifetime on this endpoint is 2 weeks.

Alongside the properties listed here, there may be other optional properties available based on the metadata available in each source tutorial file.

Query Parameters

Parameter Type Required Description
fields comma-separated string optional

Provide a comma-separated string of fields to return for the tutorial 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
id string 

The slug/identifier for the tutorial, based on the filename of the tutorial in cdnjs/tutorials.

modified string 

The timestamp of when the tutorial was last modified, in ISO 8601 format.

This is based on the last commit that touched the tutorial in cdnjs/tutorials.

created string 

The timestamp of when the tutorial was first published, in ISO 8601 format.

This is based on the first commit where the tutorial was added in cdnjs/tutorials.

name string 

The title/name for the tutorial.

content string 

The raw markdown content for the tutorial.

Example Requests

https://api.cdnjs.com/libraries/vue/tutorials/wtf-is-vuex

{"id":"wtf-is-vuex","modified":"2017-05-29T04:18:13.000Z","author":{"name":"Anthony","email":"[email protected]","description":"Web developer, author and online course instructor with Vue.js Developers","homepage":"http://vuejsdevelopers.com","twitter":"https://twitter.com/vuejsdevelopers"},"description":"Vuex is one of the most useful tools in the Vue.js ecosystem, but it can be very confusing at first. I've written this primer on Vuex to give you the background that I wish I'd had.","homepage":"http://vuejsdevelopers.com","keywords":["vue.js","vuex"],"library-tags":["vue.js","vuex"],"name":"WTF is Vuex? A Beginner's Guide To Vue's Application Data Store","repository":"https://github.com/vuejsdevelopers","content":"Vuex. Is it pronounced “vewks”, or “veweks”? Or maybe it’s meant to be “vew”, pronounced with a French-style silent “x”?\n\nMy trouble with understanding Vuex only began with the name.\n\nBeing an eager Vue developer I’d heard enough about Vuex to suspect that it must be an important part of the Vue ecosystem, even if I didn’t know what it actually was.\n\nI eventually had enough of wondering, so I went to the documentation with plans of a brief skim through; just enough to get the idea.\n\nTo my chagrin I was greeted with unfamiliar terms like “state management pattern”, “global singleton” and “source of truth”. These terms may make sense to anyone already familiar with the concept, but for me they didn’t gel at all.\n\nThe one thing I did get, though, was that Vuex had something to do with Flux and Redux. I didn’t know what those were either, but I figured it may help if I investigated them first.\n\nAfter a bit of research and persistence the concepts behind the jargon finally started to materialise in my mind. I was getting it. I went back to the Vuex documentation and it finally hit me…Vuex is freaking awesome!\n\nI’m still not quite sure how to pronounce it, but Vuex has become an essential piece in my Vue.js toolbelt. I think it’s totally worth your time to check it out too, so I’ve written this primer on Vuex to give you the background that I wish I’d had.\n\nNote: This article was originally posted [here on the Vue.js Developers blog](http://vuejsdevelopers.com/2017/05/15/vue-js-what-is-vuex/?jsdojo_id=cjs_wfv) on 2017/05/15. ..."}

Example response has been trimmed to remove text from tutorial content.

https://api.cdnjs.com/libraries/backbone.js/tutorials/cross-domain-sessions?fields=id,name,modified,author

{"id":"cross-domain-sessions","name":"Cross-domain Backbone.js with sessions using CORS","modified":"2017-09-05T17:41:17.000Z","author":{"name":"Thomas Davis","email":"[email protected]","description":"I work with a few open source projects and also work in the drone industry","homepage":"https://ajaxdavis.com/","github":"thomasdavis","twitter":"ajaxdavis"}}

Example includes fetching an extra, undocumented field (author) from this tutorial's metadata.

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/libraries/backbone.js/tutorials/this-tutorial-doesnt-exist

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

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

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