Node JS Examples: Difference between revisions
PeterHicks (talk | contribs) m Alter warning text |
PeterHicks (talk | contribs) m Tidy up tags |
||
Line 3: | Line 3: | ||
Remember to subscribe to the feed(s) you're using via the web interface! | Remember to subscribe to the feed(s) you're using via the web interface! | ||
<pre> | <pre>var prettyjson = require('prettyjson'), | ||
var prettyjson = require('prettyjson'), | |||
StompClient = require('stomp-client').StompClient; | StompClient = require('stomp-client').StompClient; | ||
Line 16: | Line 14: | ||
console.log(prettyjson.render(JSON.parse(body))); | console.log(prettyjson.render(JSON.parse(body))); | ||
}); | }); | ||
}); | });</pre> | ||
</pre> | |||
{{Navtable-DataFeeds}} | {{Navtable-DataFeeds}} |
Revision as of 16:28, 8 December 2014
node.js
Remember to subscribe to the feed(s) you're using via the web interface!
var prettyjson = require('prettyjson'), StompClient = require('stomp-client').StompClient; var destination = '/topic/TRAIN_MVT_ALL_TOC', client = new StompClient('datafeeds.networkrail.co.uk', 61618, 'emailaddress', 'your_password', '1.0'); client.connect(function(sessionId) { console.log('Trying to connect...'); client.subscribe(destination, function(body, headers) { console.log(prettyjson.render(JSON.parse(body))); }); });
Network Rail Open Data Feeds | |
---|---|
Data Feeds | About the Feeds • Account States • Durable Subscriptions • Example Code ( PHP / C# / Java / Ruby / Node.js) • Advanced Uses • FAQ • Release Notes |
RTPPM | RTPPM Feed |
Train Movements | Train Movements Feed • Train Activation • Train Cancellation • Train Movement • Train Reinstatement • Change of Origin • Change of Identity • Change of Location • TSPEED Field • Planned Cancellations • Cancellation Codes |
TD | TD Feed • C-Class Messages • S-Class Messages • Train Describers • TD Berths |
VSTP | VSTP Feed |
TSR | TSR Feed • Route Codes |
SCHEDULE | SCHEDULE Feed • TIPLOC Records • Schedule and Location Records • Association Records • CIF Codes • How Scheduling Works • Allowances |
Reference Data | Reference Data Feed • TOC Codes • CIF Codes • Delay Attribution Codes • Identifying Locations (STANOX, TIPLOC, NLC and 3-Alpha Codes) • STANOX Geographical Areas • Train Planning data (BPLAN) |