Beta API. See the stability policy.
Authentication
Almost every request to the API needs an API key. You send it in the Authorization header. A few
requests that only read public data work without one.
Get a key
- Sign in, open Account and go to the API keys tab.
- Click Create key.
- Copy the key and keep it somewhere safe, such as a password manager or your server's secret store.
ThrustLab shows the whole key only once. After that you see its first 8 and last 4 characters, which is enough to tell your keys apart.
You can't create a key through the API. That way a leaked key can't be used to make more keys.
Send the key
Put the key in the Authorization header of every request:
curl https://thrustlab.com/v1/projects \
-H "Authorization: Bearer key_..."These requests work without a key, because they only read public data:
GET /v1/components,GET /v1/components/{id}andGET /v1/components/brands, the parts catalogue. With a key you also see your own parts and the ones you've starred.- Everything under
/v1/public/. GET /v1/health.
Anything else without a key gets a 401 response.
The ThrustLab website talks to the same API with its own sign-in tokens. Those only work for the website, so your code should always use an API key.
Replace or revoke a key
To replace a key, create a new one, switch your code over to it, and then revoke the old one on the API keys tab. Creating a key never revokes another one, so both keys work until you revoke the old one. Do it in that order and nothing breaks.
If a key leaks, revoke it right away. Every request with it after that is refused.
When a key is refused
A refused request gets a 401 response. The code in the error body says why:
| Code | What went wrong |
|---|---|
missing_authorization | The request has no Authorization header. |
malformed_authorization | The header isn't in the form Bearer <key>. |
invalid_credential_format | The value after Bearer doesn't look like a key. |
invalid_api_key | The key doesn't exist, was revoked, or belongs to an account that's no longer active. |
invalid_api_key doesn't tell you which of the three it was. That makes it harder for anyone to
guess keys.
How many requests you can make
Each key can make 1,000 requests a minute. You can send up to 50 in a quick burst. Go over that
and you get a 429 response. Rate limits explains what to do then.