Originally jsDelivr API was just a JSON file Dmitriy had put together. Let's just say it's not very easy to use and you have to do a lot of work yourself to work with the data.
Given I had done some work on the domain already I thought I could write something much better in an hour or two. As a result a new API was born. This happened three months ago.
We host our service at AppFog. The API runs on multiple instances load balanced by their infrastructure. In front we use MaxCDN for caching.
Currently our API supports three popular provides. Besides jsDelivr we provide uniform access to cdnjs, Google CDN, jQuery CDN and BootstrapCDN. The API relies on scraping. The data is then stored on an in-memory database.
The scrapers are somewhat simple. In case of jsDelivr and cdnjs we simply fetch JSON and then format it a little bit. Google took more effort. In that case we rely on their HTML index and extract the data from there.
Each of our instances maintains its own state. This makes the API very scaleable. We can adjust the amount of API instances on whim. Maybe this isn't an issue yet but it doesn't hurt.
There is some overhead as each instance will scrape on its own. It would be possible to overcome the scraping problem by implementing a separate service that the instances query. Given we have only a few instances running I haven't bothered to do this yet.
The API relies on technology I have designed and implemented to make it easy to write light, RESTful APIs. rest-sugar is the most important part. To give you some idea of the API consider the examples below:
GET http://api.jsdelivr.com/v1/jsdelivr/libraries - All jsdelivr libraries GET http://api.jsdelivr.com/v1/jsdelivr/libraries?name=AngularJS - AngularJS GET http://api.jsdelivr.com/v1/google/libraries/AngularJS - Alias, getting from Google this time GET http://api.jsdelivr.com/v1/jsdelivr/libraries?name=jquery* - All libraries starting with jquery (based on [minimatch](https://www.npmjs.org/package/minimatch)) GET http://api.jsdelivr.com/v1/jsdelivr/libraries?author=angularui - All libraries of angularui GET http://api.jsdelivr.com/v1/jsdelivr/libraries?name=jquery&fields=mainfile,name - Only mainfile and name fields of jquery
In addition the API provides pagination and a couple of extra custom features have been covered at the project README.
Even though the API started out from personal curiosity, people started finding it useful. To give you some examples of usage so far, consider the projects below:
- alfred-cdn-workflow - The tool includes support for jsDelivr now
- npm-jsdelivr - This is a little CLI tool I forked and made work with the API
The API is still quite young and maybe not that many tool authors are aware of it yet. At the moment I'm planning its next revision that will unify the API further and simplify certain aspects. Your feedback is welcome as it will affect the design.
jsDelivr API is more than you might infer from its name. It provides access to the data of multiple CDNs. This is useful for tool authors and service providers. It's also an example of an API relying on scraping.