Huxley - Staff Version


Update: Huxley 2 is out now.


Huxley is my open source project that proxies the Darwin SOAP API to simple HTTP JSON, for easy use in alternative cross-platform tech stacks. It now supports a subset of the staff version of the Darwin API, which provides significantly more detail over the basic one. The documentation is at huxley.unop.uk and in the GitHub repository / wiki. It’s also deployed to a demo server so that you can try it out.

For example: https://huxley.apphb.com/StaffAll/London%20Bridge/to/cry/1?accessToken=DA1C7740-9DA0-11E4-80E6-A920340000B1

{
  "trainServices": [
    {
      "cancelReason": null,
      "delayReason": null,
      "category": "OO",
      "activities": "T           ",
      "length": 0,
      "isReverseFormation": false,
      "detachFront": false,
      "origin": [
        {
          "isOperationalEndPoint": false,
          "locationName": "London Charing Cross",
          "crs": "CHX",
          "tiploc": "CHRX",
          "via": null,
          "futureChangeToSpecified": false
        }
      ],
      "destination": [
        {
          "isOperationalEndPoint": false,
          "locationName": "Gravesend",
          "crs": "GRV",
          "tiploc": "GRVSEND",
          "via": "via Sidcup",
          "futureChangeToSpecified": false
        }
      ],
      "currentOrigins": null,
      "currentDestinations": null,
      "rid": "201609208748340",
      "uid": "W48340",
      "trainid": "2N34",
      "rsid": null,
      "sdd": "2016-09-20T00:00:00",
      "operator": "Southeastern",
      "operatorCode": "SE",
      "isPassengerService": true,
      "isCharter": false,
      "isCancelled": false,
      "isCircularRoute": false,
      "filterLocationCancelled": false,
      "filterLocationOperational": false,
      "isOperationalCall": false,
      "sta": "2016-09-20T12:30:00",
      "staSpecified": true,
      "ataSpecified": false,
      "eta": "2016-09-20T12:30:00",
      "etaSpecified": true,
      "arrivalType": 0,
      "arrivalTypeSpecified": true,
      "arrivalSource": null,
      "arrivalSourceInstance": null,
      "std": "2016-09-20T12:31:00",
      "stdSpecified": true,
      "atdSpecified": false,
      "etd": "2016-09-20T12:31:00",
      "etdSpecified": true,
      "departureType": 0,
      "departureTypeSpecified": true,
      "departureSource": "Darwin",
      "departureSourceInstance": null,
      "platform": "7",
      "platformIsHidden": false,
      "serviceIsSupressed": false,
      "adhocAlerts": null
    }
  ],
  "busServices": null,
  "ferryServices": null,
  "qos": -1.0,
  "qosSpecified": true,
  "isTruncated": true,
  "generatedAt": "2016-09-20T11:13:41.9464476+00:00",
  "locationName": "London Bridge",
  "crs": "LBG",
  "filterLocationName": "Crayford",
  "filtercrs": "CRY",
  "filterType": 0,
  "stationManager": "Network Rail",
  "stationManagerCode": "RT",
  "nrccMessages": [
    {
      "category": 0,
      "severity": 1,
      "xhtmlMessage": "Southern and Gatwick Express are currently running an amended service on some routes.&nbsp; More information can be found in <A href=\"http://nationalrail.co.uk/service_disruptions/143147.aspx\">Latest Travel News</A>."
    }
  ],
  "platformsAreHidden": false,
  "servicesAreUnavailable": false
}

The client side access token is the same for both APIs and Huxley will choose the correct Darwin access token to use. If you pass through your token then you will need to use the correct one for the API being called.

There are a bunch of extra fields on the staff API, some have been renamed and some have a different type. For example, the times are all now real DateTime objects, which makes them easier to use, rather than simply display (or do complex parsing). Something to keep in mind with the staff service details (if you pass in a RID or expand the board) is that you don’t just get calling points. You get all locations, including passed stations and junctions (for example, Borough Market Jn. and North Kent East Jn. - but you won’t get a proper location name for these, just a TIPLOC with whitespace trimmed).

There are also some improvements to the non-staff API. Huxley now returns the service ID in multiple forms (original Base64, percent encoded, GUID and URL safe Base64). The service endpoint will accept any of these and it will also attempt to patch up any malformed IDs. Plain Base64 strings don’t always play nicely in URLs (particularly if used in the path, rather than as a query string parameter).

For example: https://huxley.apphb.com/all/london%20bridge/to/cry/1?accessToken=DA1C7740-9DA0-11E4-80E6-A920340000B1

{
  "trainServices": [
    {
      "origin": [
        {
          "locationName": "London Charing Cross",
          "crs": "CHX",
          "via": null,
          "futureChangeTo": null,
          "assocIsCancelled": false
        }
      ],
      "destination": [
        {
          "locationName": "Gravesend",
          "crs": "GRV",
          "via": "via Sidcup",
          "futureChangeTo": null,
          "assocIsCancelled": false
        }
      ],
      "currentOrigins": null,
      "currentDestinations": null,
      "rsid": null,
      "sta": "12:30",
      "eta": "On time",
      "std": "12:31",
      "etd": "On time",
      "platform": "7",
      "operator": "Southeastern",
      "operatorCode": "SE",
      "isCircularRoute": false,
      "isCancelled": false,
      "filterLocationCancelled": false,
      "serviceType": 0,
      "length": 0,
      "detachFront": false,
      "isReverseFormation": false,
      "cancelReason": null,
      "delayReason": null,
      "serviceID": "laFO+Gv6M14nL0ghgo++Eg==",
      "serviceIdPercentEncoded": "laFO%2bGv6M14nL0ghgo%2b%2bEg%3d%3d",
      "serviceIdGuid": "f84ea195-fa6b-5e33-272f-4821828fbe12",
      "serviceIdUrlSafe": "laFO-Gv6M14nL0ghgo--Eg",
      "adhocAlerts": null
    }
  ],
  "busServices": null,
  "ferryServices": null,
  "generatedAt": "2016-09-20T11:03:49.5090453+00:00",
  "locationName": "London Bridge",
  "crs": "LBG",
  "filterLocationName": "Crayford",
  "filtercrs": "CRY",
  "filterType": 0,
  "nrccMessages": [
    {
      "value": "Southern and Gatwick Express are currently running an amended service on some routes.&nbsp; More information can be found in <A href=\"http://nationalrail.co.uk/service_disruptions/143147.aspx\">Latest Travel News</A>."
    }
  ],
  "platformAvailable": true,
  "areServicesAvailable": true
}

I’ve also moved Huxley into maintenance mode. Any major enhancements will be made in a new version targeting .NET Core and the .NET Standard Library (once all the frameworks have been aligned).

This version will still have bug fixes and minor updates but Huxley is fairly stable now. ASP.NET Core allows for running on more platforms, plus I can’t really write a book on it and not aim to support it.

On a related note, I’ve documented (with examples on the open rail data wiki) the Historical Service Performance (HSP) API (that’s used for the back-end of my train journey). Additionally, you may want to take a look at Transport API if you’re building something in this area.


This blog is treeware! If you found it useful then please plant a tree.
Donate a treeDonate a tree🌳🌳