Barcelona Urban Mobility Graphql API
January 3, 2021 ยท View on GitHub
GraphQL API built using Apollo Server + Typescript that integrates information about the urban mobility services of the city of Barcelona.
It provides information about bus stops and lines, metro stations/lines, and public bikes (Bicing) stations and availability.
GraphQL Playground ๐
Barcelona Urban Mobility GraphQL Playground
Usage ๐ง
Install
The installation requires node.js as the execution environment as well as npm or yarn as the package manager. Then run npm install or yarn install as a command on your commandline interface.
Run
To run it, execute yarn build, and then yarn start. The application will be available port 9000.
Generate Schema
To generate the schema and Typescript types for the schema (on src/types.d.ts), run schema. This uses GraphQL Code Generator
Test
In order to test using Jest, just run yarn test or npm run test
Data Sources ๐
Metro Stations / Bus Stops
For the metro stations and bus stops, we use the public Transports Metropolitans de Barcelona (TMB) API, at https://developer.tmb.cat/.
The App Key and App ID are passed through the node's process.env.TMB_API_APP_KEY and process.env.TMB_API_APP_ID and the credentials can be obtained if you log and register an app to the portal.
Bike Stations
For the bike stations, we use the BSMSA API for smou/bicing. The endpoints are:
https://api.bsmsa.eu/ext/api/bsm/gbfs/v2/en/station_information
https://api.bsmsa.eu/ext/api/bsm/gbfs/v2/en/station_status