Quickstart
Make your first authenticated request to the MyTrafficData API in under five minutes. We'll list the measuring sites your account has access to.
By the end of this page you'll have:
- An API token
- A working request in curl, Python, and JavaScript
- A sample JSON response you can recognize
- A clear sense of what to read next
1. Get an API token
API tokens are managed from the API Tokens page in your MyTrafficData account.
- Sign in to the MyTrafficData web app.
- Open the user menu (top-right) → API Tokens.
- Click Generate (or Regenerate if you've used the API before).
- Copy the token value immediately. The plaintext is shown exactly once — after you close the dialog, only a masked form (
abcd…wxyz) remains.
Store the token in a secret manager (or, for a quick test, an environment variable).
export MYTD_TOKEN="<your-token>"
:::warning Permission required
Your account needs the can_use_api permission to be issued a token. If the Generate button isn't visible on the API Tokens page, contact your account administrator. See Authentication & tokens for details.
:::
2. Your first request
Let's list the measuring sites accessible to your account.
curl -H "Authorization: Token $MYTD_TOKEN" \
https://mytrafficdata.com/api/v1/traffic/sites
import os
import requests
TOKEN = os.environ["MYTD_TOKEN"]
r = requests.get(
"https://mytrafficdata.com/api/v1/traffic/sites",
headers={"Authorization": f"Token {TOKEN}"},
timeout=(5, 30),
)
r.raise_for_status()
print(r.json())
const TOKEN = process.env.MYTD_TOKEN;
const r = await fetch("https://mytrafficdata.com/api/v1/traffic/sites", {
headers: {Authorization: `Token ${TOKEN}`},
});
if (!r.ok) throw new Error(await r.text());
const body = await r.json();
console.log(body);
That's it — one header, one endpoint, no SDK, no OAuth flow.
3. What success looks like
A successful response returns HTTP 200 OK with a JSON body wrapping the list of sites under items:
{
"items": [
{
"id": 42,
"site_id": "berlin-mitte-1",
"name": "Berlin Mitte — Friedrichstraße",
"description": "North-side count point",
"device_type": "sdr",
"coordinates": {
"latitude": 52.5200,
"longitude": 13.4050
},
"street_name": "Friedrichstraße",
"city": "Berlin",
"country": "DE",
"data_range": {
"first_vehicle": "2024-08-12T07:14:00+02:00",
"last_vehicle": "2026-06-29T14:32:00+02:00"
}
}
]
}
Each site comes with its internal numeric id (used in URL paths for other endpoints) and a human-readable site_id you chose at site setup. Coordinates and the data-range timestamps tell you where the site is and what time window of measurements is available.
If your account has no sites yet, the response will be {"items": []}.
4. What failure looks like
The three most common failures on your first call:
Missing the token
{
"detail": "Authentication credentials were not provided."
}
Add the Authorization: Token … header.
Wrong or revoked token
{
"detail": "Invalid token."
}
Regenerate from the dashboard. See Authentication & tokens.
Authenticated but not authorized
{
"detail": "You do not have permission to perform this action."
}
Your token works, but the account is missing the can_use_api permission. Contact your account administrator.
Every error response from /api/v1/ follows one of three shapes. The full catalog is on the Error model page.
5. Try a second endpoint
Once a site listing works, pick one of those id values and fetch the details:
curl -H "Authorization: Token $MYTD_TOKEN" \
https://mytrafficdata.com/api/v1/traffic/sites/42
You'll get the same site shape plus channels (per-direction count groupings) and the associated device's configuration number and serial.
Where to go from here
Now that your first call works, the next things to read depend on what you want to build:
- Pulling measurement data? → Pagination (the search endpoint is cursor-based with a 30-day window per query)
- Parsing timestamps? → Timezone handling
- Handling errors robustly? → Error model
- Sending too many requests? → Rate limits
- All the endpoints we expose? → API reference
- Production-ready integration tips? → Best practices
The full set of rules (authentication, versioning, breaking changes, deprecation, …) lives in the Concepts section.