REST API providing access to mobile library services, timetables, routes, stops, road trips, and live/estimated vehicle locations across the UK.
Upstream database schema and data creation scripts are maintained in LibrariesHacked/mobilelibraries-database, with data source files conforming to the national UK mobile library data standard: schema.librarydata.uk/mobile-library-stops.json (v2.0.0).
Interactive Swagger/OpenAPI documentation is available at the root URL / and raw OpenAPI 3.0 JSON specification at /openapi.json.
- Node.js (v20+)
- PostgreSQL with PostGIS extension installed (database populated via
mobilelibraries-database)
Create a .env file in the project root:
PORT=8080
PGHOST=localhost
PGPORT=5432
PGDATABASE=mobiles
PGUSER=postgres
PGPASSWORD=yourpasswordnpm installnpm startThe API will start at http://localhost:8080.
npm test
npm run lintGET /api/localauthorities: List all UK local library authorities operating mobile services.GET /api/localauthorities/:id: Get details of a local authority by numeric database ID or 9-character GSS code (e.g.S12000041,E06000004).
GET /api/mobiles?local_authority_id=: List mobile library vehicles, optionally filtered by local authority ID.GET /api/mobiles/:id: Get a single mobile library vehicle by ID.GET /api/mobiles/locations: Get current, previous, and next stops with estimated vehicle coordinates and route sections for services active today.GET /api/mobiles/nearest?longitude=&latitude=&distance=: Find mobile libraries near given WGS84 coordinates within distance in metres.
GET /api/routes?local_authority_id=&mobile_id=: List recurring service routes and frequencies, optionally filtered by authority or vehicle.GET /api/routes/:id: Get route details by ID.
GET /api/stops: Search and filter physical stop locations.- Query parameters:
local_authority_ids: Pipe-separated authority IDs (e.g.44|56)local_authority_codes: Pipe-separated 9-char GSS codes (e.g.S12000041|E06000004)mobile_ids: Pipe-separated mobile vehicle IDsroute_ids: Pipe-separated route IDslongitude,latitude,distance: Coordinates and buffer in metres for proximity filteringlimit,page: Pagination controls (defaults: limit 1000, page 1)sort,direction: Sort column and direction (asc/desc)
- Response headers:
X-Total-Count,X-Page - Formats:
Accept: application/json: JSON array of Stop objectsAccept: application/geo+json: GeoJSON Point FeatureCollection
- Query parameters:
GET /api/stops/nearest?longitude=&latitude=&limit=: Return the closest stops to coordinates.GET /api/stops/:id: Get a stop by numeric ID.GET /api/stops/:id/pdf: Download a printable timetable flyer for the stop in PDF format.GET /api/stops/:id/ics: Download an iCalendar (.ics) file containing upcoming scheduled visits.GET /api/stops/:z/:x/:y.mvt: Mapbox Vector Tile (MVT) for stop point visualization.
GET /api/trips: List driving trips between consecutive stops with road route linestrings, duration, and distance.Accept: application/jsonorAccept: application/geo+json(GeoJSON LineString FeatureCollection).
GET /api/trips/:id: Get trip details by ID.GET /api/trips/:z/:x/:y.mvt: Mapbox Vector Tile (MVT) for trip road linestrings.
Conforms strictly to the UK national standard: schema.librarydata.uk/mobile-library-stops.json (v2.0.0).
GET /api/schema: Export entire stop timetable dataset (Accept: application/jsonorAccept: text/csv).GET /api/schema/:local_authority: Export stops for a specified authority name or GSS code (Accept: application/jsonorAccept: text/csv).POST /api/schema: Import or bulk update stops into staging. Accepts JSON array or raw CSV.
- Dave Rowe - Libraries Hacked
This project is licensed under the MIT License - see the LICENSE.md file for details.