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.
Barcelona Urban Mobility GraphQL Playground
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.
To run it, execute yarn build
, and then yarn start
. The application will be available port 9000
.
To generate the schema and Typescript types for the schema (on src/types.d.ts
), run schema
. This uses GraphQL Code Generator
In order to test using Jest, just run yarn test
or npm run test
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.
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