Some API endpoints require authentication - for example, editing a kit or viewing private information such as a list of kits owned by a user. Other endpoints will give extra information when authenticated.
To authenticate as a user you need to pass a token to the API. You can generate a user token on your API Token page on Typekit. In the future we plan to add delegated authentication flows allowing an app to request access to a user accounts.
You can authenticate as a user by sending a X-Typekit-Token
HTTP header. For example:
$ curl -s -H X-Typekit-Token:4d6141e7c82cb30affebcc392abc2ce3ab0ea4c1 http://typekit.com/api/v1/json/kits | jsonpretty
{
"kits": [
{
"id": "ajd4dmw",
"link": "/api/v1/json/kits/ajd4dmw"
},
{
"id": "ard8twk",
"link": "/api/v1/json/kits/ard8twk"
}
]
}
If you don't have the ability to set custom HTTP headers, you can also pass a token as a parameter to the API. For example:
$ curl -s https://typekit.com/api/v1/json/kits?token=4d6141e7c82cb30affebcc392abc2ce3ab0ea4c1
{
"kits": [
…
]
}
All authenticated API requests must be made over a secure HTTPS connection.