# Digitraffic API

Category: [Transport](https://free-web-services.com/web-services/open-data/transport/)  
Page: https://free-web-services.com/web-services/open-data/transport/digitraffic-api.html  
Documentation: https://www.digitraffic.fi/en/

Digitraffic from Fintraffic gives live traffic data for Finland's roads, railways and waters, for example to show the next trains from Helsinki or follow ships at sea. It has REST APIs with JSON answers, and a GraphQL API for rail data. Free, no key needed; the data is under CC BY 4.0, so credit Fintraffic / digitraffic.fi. Ask for gzip compression on requests, and send a Digitraffic-User header naming your app to get a higher rate limit.

- API key: Not needed
- Pricing: Free, no key needed; the data is under CC BY 4.0, so credit Fintraffic / digitraffic.fi.
- Commercial use: Allowed on the free plan
- From the browser: Yes (CORS)
- Formats: JSON
- Interface: REST, HTTP-GET, GraphQL
- Provider: digitraffic.fi

Example request:

```sh
curl 'https://rata.digitraffic.fi/api/v1/live-trains/station/HKI?arriving_trains=0&departing_trains=5&arrived_trains=0&departed_trains=0' \
  -H 'Accept-Encoding: gzip' \
  -H 'Digitraffic-User: ExampleUser/ExampleApp' \
  --compressed
```

The JavaScript works in a web page as well as in Node.js 18 or newer.

