Giter Club home page Giter Club logo

transport-apis's Introduction

list of transport APIs

This is a machine-readable list of (public) transport API endpoints, with details about who operates them, the protocol used & authentication details.

Format

Overall Structure

There is a single JSON file per API endpoint. It must contain the following properties:

  • name: endpoint name
  • type: endpoint protocol description (see below)
  • supportedLanguages: list of supported languages (see below)
  • coverage: the geographic area this endpoint provides results for (see below)
  • options: protocol-specific options (not specified here)

Endpoint Protocol

{
    "type": {
        "hafasMgate": true
    }
}

Known protocols:

  • efa
  • hafasMgate
  • hafasQuery
  • navitia
  • otpGraphQl
  • otpRest
  • trias
  • motis

Supported Languages

{
    "supportedLanguages": [
        "en",
        "de",
        "fr",
        "es"
    ]
}

A list of ISO-639-1 language codes describing the languages supported by the endpoint.

Timezone Information

{
    "timezone": "Europe/Berlin"
}

For endpoints that assume times in requests to be in a specific local timezone, the timezone field should contain the IANA timezone identifier of the expected timezone. This timezone can also be applied by clients to times in results returned by the endpoint, particularly when the results are lacking explicit timezone (offset) information.

Coverage Information

Describes the geographic area this endpoint provides results for.

{
    "coverage": {
        "realtimeCoverage": { /* ... */ },
        "regularCoverage": { /* ... */ },
        "anyCoverage": { /* ... */ }
    }
}

There's three coverage categories:

  • realtimeCoverage: In this area the endpoint provides accurate and highly detailed information. This is typically where the operator can rely on live data about their own vehicles.

  • regularCoverage: In this area reasonably complete data is available, but e.g. realtime data from other operators is missing or inaccurate quite often.

  • anyCoverage: In this area only incomplete and/or shallow data is available. This is commonly the case in areas outside the operating area, e.g. long-distance trains & buses but not local modes of transport, or planned data but not realtime data. You could say that this is the extent to which, in a region, the API provides any data.

At least one coverage category must be provided.

{
    "area": { /* GeoJSON polygon or MultiPolygon */ },
    "region": [ /* ISO-3166-1/2 codes */ ]
}

The following properties are defined for each coverage category:

  • area: a GeoJSON Polygon or MultiPolygon defining the geographic area. This can be reasonably coarse; meter-precision is neither necessary nor practically meaningful. It should fully cover the area, but does not need to add additional buffers/offsets beyond that.
  • region: an array of ISO-3166-1 alpha 2 country codes, or ISO-3166-2 region codes covered.

Both fields should be provided.

Attribution Information

The attribution property specifies licensing information for an endpoint.

Open Data

If an endpoint provides results under an Open Data license, attribution generally follows the Data Packages format:

{
    "attribution": {
        "name": "© Helsinki Region Transport",
        "license": "CC-BY-4.0",
        "homepage": "https://www.hsl.fi/"
    }
}

Properties:

name and license are mandatory, homepage is optional.

For endpoints aggregating data under various Open Data licenses, the situation can be more complex than this though, making it impossible to specify a single license. This can be expressed using the mixedLicenses property:

{
    "attribution": {
        "name": "© navitia.io",
        "homepage": "https://www.navitia.io/",
        "mixedLicenses": true
    }
}

If mixedLicenses is set to true, the license details are provided in some other form. This can be for example via the homepage property, or as part of the endpoint responses themselves.

Proprietary

If an endpoint is known to be proprietary, attribution can be used to specify this as well:

{
    "attribution": {
        "isProprietary": true
    }
}

Protocol Specific Options

Hafas mgate.exe

"options": {
    "auth": {
        "aid": "...",
        ...
    },
    "checksumSalt": "<hex value>",
    "client": {
        "id": "...",
        "type": "...",
        ...
    },
    "ext": "...",
    "micMacSalt": "<hex value>",
    "version": "1.27",
    "products": [
        {
            id: 'subway',
            name: 'U-Bahn'
            bitmasks: [1]
        },
        {
            id: 'suburban',
            bitmasks: [2],
            name: 'S-Bahn'
        },
        ...
    ]
}

The following properties are defined:

  • auth: JSON object with static authentication information as passed verbatim in Hafas requests. Mandatory for all known endpoints.
  • checksumSalt: A string containing a hexadecimal representation of the salt to hash the request body with. Mandatory for endpoints using this authentication mechanism.
  • client: JSON object with static client information passed verbatim in Hafas requests.
  • ext: String with the extension version (?) included in Hafas request.
  • micMacSalt: A string containing a hexadecimal representation the salt to hash the hashed request body with. Mandatory for endpoints using this authentication mechanism.
  • version: String containing the requested Hafas API version (?), mandatory for all known endpoints.
  • products: Information about the Hafas product bitmask values and the corresponding product metadata (see below).

Product metadata consists of the following information:

  • id: An URL-safe slug-ified version of the name, for machine use.
  • name: A human-readable label for the product, as used by the operator.
  • bitmasks: An array of integer values of bit values used by Hafas for this product.

Hafas query.exe

"options": {
    "endpoint": "https://.../",
    "products": [
        {
            id: 'subway',
            name: 'U-Bahn'
            bitmasks: [1]
        },
        {
            id: 'suburban',
            bitmasks: [2],
            name: 'S-Bahn'
        },
        ...
    ]
}

The following properties are defined:

  • endpoint: The base URL containing the various endpoints (query.exe, stboard.exe, etc).
  • products: Hafas product metadata, see the Hafas mgate.exe variant above for the format details.

EFA

"options": {
    "endpoint": "https://...",
    "supportedOutputFormats": [ "XML", "JSON" ],
    "xmlOutputFormat": "full",
    "mId": "...",
    "stopfinderRequestCommand": "XSLT_STOPFINDER_REQUEST",
    "dmRequestCommand": "XSLT_DM_REQUEST",
    "tripRequestCommand": "XSLT_TRIP_REQUEST2"
}

The following properties are defined:

  • endpoint: Base URL for EFA requests, mandatory.
  • supportedOutputFormats: an array of strings containing valid arguments to the outputFormat parameter of an EFA query (XML and/or JSON).
  • xmlOutputFormat: a string specifying the XML output format variant, either full or compact.
  • mId: Value of the mId query argument. Omitted if not set.
  • stopfinderRequestCommand: The command used for stop finder requests (default: XML_STOPFINDER_REQUEST).
  • dmRequestCommand: The command used for departure monitor requests (default: XML_DM_REQUEST).
  • tripRequestCommand: The command used for trip requests (default: XML_TRIP_REQUEST2).

Open Trip Planner with GraphQL

"options": {
    "endpoint": "https://...",
    "apiVersion": "otp2"
}

The following properties are defined:

  • endpoint: Base URL for the API, without e.g. the index/graphql suffix.
  • apiVersion: One of otp1, otp2 or entur.

TRIAS

The following properties are defined:

  • endpoint: Base URL for the API
  • isTestingEndpoint: Whether the endpoint is explicitly meant for testing purposes
  • triasVersion: Highest TRIAS version supported by the API
  • requestContentType: Content-Type e.g. text/xml
  • requiresSignUp: Whether one needs to sign up to obtain an API key.
  • requiresContract Whether one needs to sign a contract to use the API.
  • authorizationMethod: One of Authorization-Header, RequestorRef
  • providedServices: array of supported services as listed in the EKAP documentation
  • requestLimitPolicy: request-policy in the markup of the RateLimit HTTP header

MOTIS

The following properties are defined:

  • endpoint: Base URL for the API
  • motisVersion: version of the motis-server

Contributing

Note that, by participating in this project, you commit to the code of conduct. If you want to contribute to this list, feel free to open an Issue at the Issues page.

transport-apis's People

Contributors

1maxnet1 avatar alkino avatar derf avatar derhuerst avatar gerdc avatar vkrause avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

transport-apis's Issues

otpGraphQL: remove supportedTransitModes field

I found that in

"supportedTransitModes": [ "TRANSIT", "CARPOOL" ]
and
"supportedTransitModes": [ "TRANSIT", "CARPOOL" ]
an option called "supportedTransitModes" is used. However it is not mentioned in the protocol specific options: https://github.com/public-transport/transport-apis#open-trip-planner-with-graphql

So imho it would make sense to add it there and maybe link to the possible values (e.g. this https://docs.opentripplanner.org/en/dev-2.x/RoutingModes/ if I'm not mistaken).

If you agree I could make a little PR adding the documentation

document OJP/TRIAS APIs

@andaryjo started doing this in the trias-client docs.
@vkrause's kpublictransport also has support for >1 TRIAS endpoint.

Let's define a way to specify all relevant aspects of TRIAS API endpoints in a machine-readable way, so that client libraries can use this information! This way, there will be

  • less maintenance, as upstream changes to the individual endpoints will only have to be investigated once.
  • better coverage of all existing API endpoints, as client libraries can easily pull the list of all known ones.

version field for Trias

To my surprise, bwegt-trias.json now supports Trias 1.2 without me noticing before.

If the request contains <Trias version="1.1", it answers like a Trias 1.1.
If the request contains <Trias version="1.2", it answers like a Trias 1.2.
The same holds for VVO Trias.

Before I write a PR updating those values, I'd like to discuss the Trias Schema:

It might be valuable for a client to know that a Trias instance supports version 1.1 AND 1.2.

Storing this information appears to be not possible with the current JSON schema.

Document Motis APIs

You might know about MOTIS: https://motis-project.de/

As part of my job I started to work on a library to communicate with Motis-Instances and came to the point that it would make sense to have configuration files. So instead of creating my own format I would like to discuss the format here and ideally upstream the specification to this repo instead. Compared to TRIA, Hafas, EFA, etc. I am not aware of any "official" MOTIS-Servers provided by a public transport provider, but there are public instances like https://europe.motis-project.de/.

I also created a upstream issue here: motis-project/motis#276

If you have any additional aspects you would think about let me know in this issue. And if you would be fine adding the specification to this repository, I would similar to the TRIAS create a draft PR to discuss a proposed format.

document on-board passenger information APIs

In derhuerst/live-icomera-position#3, @Adwirawien proposed to have a central place to collect machine-readable knowledge about on-board (as in: available in the vehicle-local WiFi) APIs:

[...] I [...] noticed the wifi-on-ice-portal-client as well as digital-im-regio-portal-client and a few others. From what I can tell they are more or less all using the same icomera api with a few exceptions.

[...] This would prevent the sort of chaos, that we're noticing regarding public transport information apis and could act as a central place for documentation of all the available on-board information systems.

[...] it would be useful to have a central place, much like what WoBike is for bike/scooter sharing APIs, or transport-apis.

Let's focus the discussion here on how to add data to transport-apis, and keep the general discussion on how to obtain it and potential future projects building on top over at derhuerst/live-icomera-position#3.

What do you think @derf?

How to document endpoints blocking certain user-agents?

In #53 I discovered that the bwegt-trias-endpoint blocks certain user-agent headers, as described here: https://python.tutorialink.com/post-request-to-trias-api-does-not-work-with-requests/

This seems to be a very weird issue and is rarely documented anywhere. However it would might make sense to document it in the .json as well, as else the requests will fail with 502 Error code, with no obvious reason. @derhuerst mentioned a similar issue in his comment I contacted a contact at nvbw regarding this issue and will update the issue when I get an answer. The solution for me was just to set the user-agent manually to a working string.

Some naive possibilities how to document the blocked user-agents:

  • List all/some known working user-agents: This list will never be complete and can be exhausting, also usually the User-agent is used to identify a client. Manipulating it, does not make to much semantic sense and in my opinion (imo.) is rather a workaround then a fix.
  • List all/some known to be blocked/broken user-agents: This would be never complete as well, but could be an easier list as people who trigger the problem could look up the list and check their clients user-agent and implement a workaround or contact upstream to fix it on the endpoint side. Personally I would prefer the second option.
  • Instead of listing the known/broken user-agents we could document them in a markdown file as examples and give the users of this repository a starting point. This list would not need to be exhausting, but also couldn't be utilized by clients.
  • We could also keep this issue rather general and start in a markdown file / the GitHub wiki a list of common technical issues and how to prevent them. This imo. would be such an issue. Especially if further similar issues exist, this would be an easy way to deal with the issue.

If anyone has any thoughts on that, or did encounter this issue as well, I would appreciate some opinions :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.