TSJL - GTFS - Query URLs

URL-scheme with REST links


Server tries to provide all data with longest possible TTL-validity. Because of this, short links (like http://data.foli.fi/gtfs/agency) does not contain any actual data but instead information about from where the latest actual data is to be found.

When client fetches short baselink, it receives HTTP 302 Redirect reply ALSO containing JSON-formatted object about available datasets and actual location of requested data. Browsers follow this redirect automatically, if some client framework doesn't, it can pick further location to go from that JSON-content.

What happens in wire is :

pri:~$ telnet data.foli.fi 80
Connected to siri.foli.fi.
Escape character is '^]'.
GET /gtfs/stops HTTP/1.0
Host: data.foli.fi

HTTP/1.1 302 Moved Temporarily
Server: nginx
Date: Sat, 23 May 2015 16:05:14 GMT
Content-Type: text/json;charset=utf-8
Connection: close
Location: http://data.foli.fi/gtfs/v0/20150523-123805/stops
X-Cache-Gate: EXPIRED

    "host": "data.foli.fi",
    "gtfspath": "\/gtfs\/v0",
    "datasets": [
    "latest": "20150523-123805",
    "go": "http:\/\/data.foli.fi\/gtfs\/v0\/20150523-123805\/stops"

In case there is not auto-follow available, you can pick actual location of data from reply :

pri:~$ .... | php -r 'print_r(json_decode(file_get_contents("php://stdin")));'
    [host] => data.foli.fi
    [gtfspath] => /gtfs/v0
    [datasets] => Array
            [0] => 20150523-123805

    [latest] => 20150523-123805
    [go] => http://data.foli.fi/gtfs/v0/20150523-123805/stops

The practice if there is need to point to coherent data

(With absolute bad luck someone uploads new dataset just in between of your queries...)

  1. Aquire listing of available datasets
  2. http://data.foli.fi/gtfs
        "host": "data.foli.fi",
        "gtfspath": "\/gtfs\/v0",
        "datasets": [
        "latest": "20150523-123805",
        "success": false,
        "subpaths": [
  3. Point your further queries directly to dataset skipping short link redirections.
  4. http://data.foli.fi/gtfs/v0/20150523-123805/agency