Typekit API output formats

All Typekit API data is available in JSON, XML and YAML formats. The JSON format is optionally available wrapped in a callback.

You can request a particular format using the :format url parameter. For example, we can request the library list in XML format:

$ curl -s https://typekit.com/api/v1/xml/libraries
<libraries>
  <library>
    <name>Trial Library</name>
    <id>trial</id>
    <link>/api/v1/xml/libraries/trial</link>
  </library>
  <library>
    <name>Personal Library</name>
    <id>personal</id>
    <link>/api/v1/xml/libraries/personal</link>
  </library>
  <library>
    <name>Full Library</name>
    <id>full</id>
    <link>/api/v1/xml/libraries/full</link>
  </library>
</libraries>

JSON with callbacks

The JSON format is optionally available wrapped in a javascript callback function (also known as "JSONP")

To specify a callback, use the callback parameter.

This option is intended to be used by Javascript running in a browser and behaves differently to other output formats:

  • HTTP status codes are not used. The API will only respond to a JSONP request with a status of 200 or 302.
  • An additional request object is provided in the output giving extra metadata about the API request including the HTTP status code that would have been used.
  • For security reasons, authenticated API requests are currently unavailable with callbacks.

For example, we can get a list of font families using jQuery:

$.getJSON("http://typekit.com/api/v1/json/libraries/full?callback=?", function(data){
  alert('There are ' + data.library.pagination.count + ' font families in the full Typekit library');
});

A more detailed example of using the Typekit API from Javascript is available from GitHub.

Structure of output

We won't remove properties from or otherwise change the structure of the API's output without introducing a new API version, but we may add properties to various endpoints in the future, and the order of properties is never predetermined. Therefore, when parsing API output you should never depend on a specific order of properties, and you should always be prepared to encounter unexpected properties.