National Rail Data Portal: Difference between revisions
EvelynSnow (talk | contribs) m add missing bullet |
EvelynSnow (talk | contribs) More information, examples |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
The '''National Rail Data Portal''' is National Rail's data platform, through which users can subscribe to [[HSP]], [[Darwin:Push_Port|Darwin]], [[DTD]], and [[KnowledgeBase]]. The platform is | The '''National Rail Data Portal''' is National Rail's data platform, through which users can subscribe to [[HSP]], [[Darwin:Push_Port|Darwin]], [[DTD]], and [[KnowledgeBase]]. The platform is capable of delivering CIGP (''Customer Information GPS Platform'') and CTI (''Connecting Train Identifiers''); these APIs and feeds aren't currently available to open data users. | ||
== Authentication | Only the Knowledgebase API and DTD are available directly through NRDP's API, the other subscriptions (including real-time KB incidents) are accessed externally, using the information included in the ''My Feeds'' tab. | ||
New users can register using the [https://opendata.nationalrail.co.uk/registration registration form] on https://opendata.nationalrail.co.uk/ | |||
= CIGP and CTI = | |||
CIGP (''Customer Information GPS Platform''), also referred to as TLMS (''Train Location Monitoring System''), locates services physically using GPS data provided by train operators, CTI (''Connecting Train Identifiers'') corresponds services to the specific trains which run them. These were first announced in the Joint Rail Data Action Plan in 2018,<ref>https://www.gov.uk/government/publications/joint-rail-data-action-plan/joint-rail-data-action-plan-addressing-barriers-to-make-better-use-of-rail-data#annex-a-list-of-rdgs-future-data-releases - Joint Rail Data Action Plan (Annex A) (2018)</ref>, and went live with version 3 of the NRDP in early 2019<ref>https://groups.google.com/g/openraildata-talk/c/0jqtX-Se3mo/m/xzB-bwyZAwAJ - NRDP Phase 3 Live (2019)</ref>, but neither has been made available to open data users, owing to operator reluctance and security concerns.<ref>https://groups.google.com/g/openraildata-talk/c/6FH9doR_O_w/m/TZSpXbJ4DAAJ - Train GPS data (2019)</ref> CIGP and CTI both have API and real-time components<ref>https://opendata.nationalrail.co.uk/main.2fe5da105724f586305e.js - NRDP "main" javascript file, col 360696 and 361613 (CIGP), col 362535 and 363445 (CTI)</ref>, but no documentation has been published on either. | |||
= Authentication = | |||
To authenticate, POST to https://opendata.nationalrail.co.uk/authenticate with form parameters "username" and "password" set accordingly - the request must be urlencoded, and not multipart. | To authenticate, POST to https://opendata.nationalrail.co.uk/authenticate with form parameters "username" and "password" set accordingly - the request must be urlencoded, and not multipart. | ||
Line 44: | Line 51: | ||
</pre> | </pre> | ||
The token should be supplied with each request made to NRDP in the <code>X-Auth-Token</code> header, e.g. | = Authenticating requests = | ||
The token should be supplied in full with each request made to NRDP in the <code>X-Auth-Token</code> header, e.g. | |||
<pre> | <pre> | ||
curl 'https://opendata.nationalrail.co.uk/api/staticfeeds/2.0/routeing' \ | curl 'https://opendata.nationalrail.co.uk/api/staticfeeds/2.0/routeing' \ | ||
Line 61: | Line 70: | ||
} | } | ||
</pre> | </pre> | ||
= Endpoints = | |||
== NRDP == | |||
All NRDP endpoints return JSON | |||
=== https://opendata.nationalrail.co.uk/api/feeds === | |||
Contents of the feeds page, including feed URLs and credentials | |||
=== https://opendata.nationalrail.co.uk/api/feeds/available === | |||
Available feeds, not user-specific, but platform-wide. Doesn't offer any information that isn't already a given. | |||
* <code>"DARWIN"</code> - Darwin | |||
* <code>"DTD"</code> - Fares, Routeing Guide and Timetable data | |||
* <code>"KB_API"</code> - Knowledgebase (KB) API | |||
* <code>"KB_REAL_TIME"</code> - Knowledgebase (KB) Real Time Incidents | |||
* <code>"HSP"</code> - Historical Service Performance (HSP) | |||
* <code>"CIGP_API"</code> - Customer Information GPS Platform (CIGP) API | |||
* <code>"CIGP_REAL_TIME"</code> - Customer Information GPS Platform (CIGP) Real Time Feed | |||
* <code>"CTI_API"</code> - Connecting Train Identifiers (CTI) API | |||
* <code>"CTI_REAL_TIME"</code> - Connecting Train Identifiers (CTI) Real Time Feed | |||
Example | |||
<pre>["DTD","KB_API","KB_REAL_TIME","DARWIN","HSP"]</pre> | |||
=== https://opendata.nationalrail.co.uk/api/user === | |||
Can be used to either get (GET) or update (POST) user information, the same JSON object is used for both, simply set the changed values (e.g. to enable HSP in the below example, set "hspUser" to true) | |||
Example | |||
<pre> | |||
{ | |||
"telephone":"", | |||
"cigpApiUser":false, | |||
"cigpRealTimeUser":false, | |||
"ctiApiUser":false, | |||
"ctiRealTimeUser":false, | |||
"darwinUser":true, | |||
"dtdUser":false, | |||
"hspUser":false, | |||
"kbApiUser":true, | |||
"kbRealTimeUser":true, | |||
"business":null, | |||
"email":"alice@example.com", | |||
"name":"Alice Smith", | |||
"plannedUsage":"", | |||
"usageDetails": | |||
{ | |||
"website":"https://example.com/~alice/ldb", | |||
"screens":"", | |||
"researchAndDevelopment":"", | |||
"applications":"", | |||
"software":"AliceLDB", | |||
"dataFeedIntegration":"", | |||
"other":"" | |||
} | |||
} | |||
</pre> | |||
== DTD == | |||
All [[DTD]] feeds are ZIP files | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/2.0/fares | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/2.0/routeing | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/3.0/timetable | |||
== KB API == | |||
All [[KnowledgeBase|KB]] API feeds are XML | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/serviceIndicators | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/5.0/incidents | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/tocs | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/ticket-restrictions | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/ticket-types | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/promotions-publics | |||
* https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/stations | |||
= References = | |||
<references /> | |||
{{Navtable-NreDataFeeds}} | |||
[[Category:National Rail Enquiries Data Feeds]] |
Latest revision as of 15:37, 18 December 2023
The National Rail Data Portal is National Rail's data platform, through which users can subscribe to HSP, Darwin, DTD, and KnowledgeBase. The platform is capable of delivering CIGP (Customer Information GPS Platform) and CTI (Connecting Train Identifiers); these APIs and feeds aren't currently available to open data users.
Only the Knowledgebase API and DTD are available directly through NRDP's API, the other subscriptions (including real-time KB incidents) are accessed externally, using the information included in the My Feeds tab.
New users can register using the registration form on https://opendata.nationalrail.co.uk/
CIGP and CTI
CIGP (Customer Information GPS Platform), also referred to as TLMS (Train Location Monitoring System), locates services physically using GPS data provided by train operators, CTI (Connecting Train Identifiers) corresponds services to the specific trains which run them. These were first announced in the Joint Rail Data Action Plan in 2018,[1], and went live with version 3 of the NRDP in early 2019[2], but neither has been made available to open data users, owing to operator reluctance and security concerns.[3] CIGP and CTI both have API and real-time components[4], but no documentation has been published on either.
Authentication
To authenticate, POST to https://opendata.nationalrail.co.uk/authenticate with form parameters "username" and "password" set accordingly - the request must be urlencoded, and not multipart.
For example, if the username was alice@example.com
, and the password was hunter2%^
, the request would look like this:
POST /authenticate HTTP/1.1 Host: opendata.nationalrail.co.uk Content-Type: application/x-www-form-urlencoded Content-Length: 51 username=alice%40example.com&password=hunter2%25%5E
Using curl:
curl 'https://opendata.nationalrail.co.uk/authenticate' \ --data-urlencode 'username=alice@example.com' \ --data-urlencode 'password=hunter2%^'
Successful authentication should yield a JSON object with three keys.
username
is self-explanatory.roles
contains only the roles your account has, this example is missingROLE_DTD
andROLE_HSP_USER
, because the user is not subscribed to them.token
is your authentication token, which includes your username, the time the token will expire (expressed in milliseconds since the UNIX epoch), and finally the secret.
{ "username":"alice@example.com", "roles": { "ROLE_DARWIN":true, "ROLE_KB_REAL_TIME":true, "ROLE_STANDARD":true, "ROLE_KB_API":true }, "token":"alice@example.com:1702858757000:JAlA9FAzcdFAfDAZX8a1JYIsXaa4uFNDI0qaePaXRQA=" }
If the username or password are invalid:
{"error":"Invalid username/password"}
Authenticating requests
The token should be supplied in full with each request made to NRDP in the X-Auth-Token
header, e.g.
curl 'https://opendata.nationalrail.co.uk/api/staticfeeds/2.0/routeing' \ -H 'X-Auth-Token: alice@example.com:1702858757000:JAlA9FAzcdFAfDAZX8a1JYIsXaa4uFNDI0qaePaXRQA=' \ --output routeing.zip
If the token is expired or invalid, instead of the routeing zip:
{ "timestamp": "2023-12-18T00:56:23.284+0000", "status": 401, "error": "Unauthorized", "message": "Unauthorized", "path": "/api/staticfeeds/2.0/routeing" }
Endpoints
NRDP
All NRDP endpoints return JSON
https://opendata.nationalrail.co.uk/api/feeds
Contents of the feeds page, including feed URLs and credentials
https://opendata.nationalrail.co.uk/api/feeds/available
Available feeds, not user-specific, but platform-wide. Doesn't offer any information that isn't already a given.
"DARWIN"
- Darwin"DTD"
- Fares, Routeing Guide and Timetable data"KB_API"
- Knowledgebase (KB) API"KB_REAL_TIME"
- Knowledgebase (KB) Real Time Incidents"HSP"
- Historical Service Performance (HSP)"CIGP_API"
- Customer Information GPS Platform (CIGP) API"CIGP_REAL_TIME"
- Customer Information GPS Platform (CIGP) Real Time Feed"CTI_API"
- Connecting Train Identifiers (CTI) API"CTI_REAL_TIME"
- Connecting Train Identifiers (CTI) Real Time Feed
Example
["DTD","KB_API","KB_REAL_TIME","DARWIN","HSP"]
https://opendata.nationalrail.co.uk/api/user
Can be used to either get (GET) or update (POST) user information, the same JSON object is used for both, simply set the changed values (e.g. to enable HSP in the below example, set "hspUser" to true)
Example
{ "telephone":"", "cigpApiUser":false, "cigpRealTimeUser":false, "ctiApiUser":false, "ctiRealTimeUser":false, "darwinUser":true, "dtdUser":false, "hspUser":false, "kbApiUser":true, "kbRealTimeUser":true, "business":null, "email":"alice@example.com", "name":"Alice Smith", "plannedUsage":"", "usageDetails": { "website":"https://example.com/~alice/ldb", "screens":"", "researchAndDevelopment":"", "applications":"", "software":"AliceLDB", "dataFeedIntegration":"", "other":"" } }
DTD
All DTD feeds are ZIP files
- https://opendata.nationalrail.co.uk/api/staticfeeds/2.0/fares
- https://opendata.nationalrail.co.uk/api/staticfeeds/2.0/routeing
- https://opendata.nationalrail.co.uk/api/staticfeeds/3.0/timetable
KB API
All KB API feeds are XML
- https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/serviceIndicators
- https://opendata.nationalrail.co.uk/api/staticfeeds/5.0/incidents
- https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/tocs
- https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/ticket-restrictions
- https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/ticket-types
- https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/promotions-publics
- https://opendata.nationalrail.co.uk/api/staticfeeds/4.0/stations
References
- ↑ https://www.gov.uk/government/publications/joint-rail-data-action-plan/joint-rail-data-action-plan-addressing-barriers-to-make-better-use-of-rail-data#annex-a-list-of-rdgs-future-data-releases - Joint Rail Data Action Plan (Annex A) (2018)
- ↑ https://groups.google.com/g/openraildata-talk/c/0jqtX-Se3mo/m/xzB-bwyZAwAJ - NRDP Phase 3 Live (2019)
- ↑ https://groups.google.com/g/openraildata-talk/c/6FH9doR_O_w/m/TZSpXbJ4DAAJ - Train GPS data (2019)
- ↑ https://opendata.nationalrail.co.uk/main.2fe5da105724f586305e.js - NRDP "main" javascript file, col 360696 and 361613 (CIGP), col 362535 and 363445 (CTI)
National Rail Enquiries Data Feeds | |
---|---|
Data Feeds | About the Feeds • Darwin Webservice (Public) • Darwin Webservice (Staff) • Historical Service Performance • Push Port • KnowledgeBase • DTD • Locations (PoC) • Real Time Journey Planner |
LDB API | About |
LDB-SV API | About |
HSP | About |
DTD | About • Fares • Timetable |
Push Port | About • XML Schemas • Schedules • Associations • Train Status • Station Messages • Alarms • Train Order • Train Alerts • Formations • Formation loading |