Transport for The Netherlands API

Transportation / API Key Intermediate HTTP
Varies by plan (check documentation)

Overview

Transport for The Netherlands (NS API) provides real-time and scheduled train data for Dutch national rail operator NS. You can retrieve train timetables, live departures, delays, and journey planning information. An API key is required and can be requested through the NS developer portal at apiportal.ns.nl.

💡

Beginner Tip

Request your API key at apiportal.ns.nl — approval is usually quick. Use the /reisinformatie-api/api/v3/departures endpoint with a station code such as "ASD" for Amsterdam Centraal to get live departure boards.

Available Data

match scores and results
team standings
player statistics
schedule and fixtures
Use case: Integrate ns, only trains data into web and mobile applications

Example Response

JSON Response
{
  "route": "Line 1",
  "origin": "Station A",
  "destination": "Station B",
  "departure": "08:30",
  "arrival": "09:15",
  "status": "On Time",
  "delays_min": 0
}

Field Reference

payload.departures List of upcoming departures from the station.
payload.departures[].direction Final destination of the train service.
payload.departures[].plannedDateTime Planned departure time in ISO 8601 format.
payload.departures[].actualDateTime Actual or expected departure time, reflecting any delays.
payload.departures[].trainCategory Category of the train (e.g., IC, SPR, Intercity Direct).
payload.departures[].departureStatus Current status of the departure (e.g., ON_STATION, DEPARTED).

Implementation Example

const url = "http://www.ns.nl/reisinformatie/ns-api";
// Replace headers or query params with the values required by this API.
const response = await fetch(url, {
  headers: {
  "X-API-Key": "YOUR_API_KEY"
  }
});
if (!response.ok) throw new Error(`Request failed: ${response.status}`);
const data = await response.json();
console.log(data);

What Can You Build?

Note: These code examples are AI-generated and unverified. Always refer to the official API documentation for accurate usage.

Common Errors & Troubleshooting

403 Forbidden Your API key does not have access to the requested endpoint or subscription.
Check your subscription tier on the NS API portal and ensure your key has the required permissions.
Invalid station code Using full station names instead of NS station codes.
Use the /reisinformatie-api/api/v2/stations endpoint to look up station codes before querying departures.
401 Unauthorized API key is not included or is invalid in the request header.
Pass your key as: Ocp-Apim-Subscription-Key: YOUR_API_KEY in the request header.

Matrix Score Breakdown

🌐 Reachability 30/30
⚡ Speed 10/20
🔒 Security 5/15
🛠 Developer XP 12/20
✓ Reliability 10/15

Partially tested on Apr 5, 2026

Technical Specifications

Auth API Key
HTTPS NO
CORS UNKNOWN
Category Transportation
Difficulty Intermediate
Verified: 2026-04-04

Similar APIs

View All →