npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

gtfs-bods

v1.0.0

Published

A CLI tool for processing UK Bus Open Data Service (BODS) GTFS data - import, export, and query transit data with ease

Downloads

30

Readme

GTFS BODS CLI

npm version Node.js Version

A powerful command-line tool for processing UK Bus Open Data Service (BODS) GTFS data. Import GTFS zip files into SQLite databases, query transit data, and export back to GTFS format with ease.

🚀 Quick Start

Installation

Install globally via npm:

npm install -g gtfs-bods

Basic Usage

# Import GTFS zip file to SQLite database
gtfs-bods import ./data.zip ./gtfs.db

# Query the database
gtfs-bods query ./gtfs.db --report

# Export back to GTFS format
gtfs-bods export ./gtfs.db ./output-gtfs/

# Get file information
gtfs-bods info ./data.zip

📋 Commands

import - Import GTFS Data

Convert a GTFS zip file into a SQLite database:

gtfs-bods import <zip-file> <db-file> [options]

Examples:

# Basic import
gtfs-bods import ./london-buses.zip ./london.db

# Import with custom agency key
gtfs-bods import ./data.zip ./gtfs.db --agency-key london-transport

Options:

  • -k, --agency-key <key> - Custom agency key (default: 'gtfs-data')
  • -v, --verbose - Enable verbose logging

export - Export to GTFS Format

Export SQLite database back to GTFS text files:

gtfs-bods export <db-file> <output-dir> [options]

Examples:

# Export to directory
gtfs-bods export ./gtfs.db ./exported-gtfs/

# Export with custom agency key
gtfs-bods export ./gtfs.db ./output/ --agency-key london-transport

Options:

  • -k, --agency-key <key> - Agency key to export (default: 'gtfs-data')
  • -v, --verbose - Enable verbose logging

query - Query Database

Query and analyze GTFS data:

gtfs-bods query <db-file> [options]

Examples:

# Basic statistics
gtfs-bods query ./gtfs.db

# Comprehensive report
gtfs-bods query ./gtfs.db --report

# List all agencies
gtfs-bods query ./gtfs.db --agencies

# List routes
gtfs-bods query ./gtfs.db --routes

# List stops
gtfs-bods query ./gtfs.db --stops

# Find stops in geographic area (London area example)
gtfs-bods query ./gtfs.db --area "51.3,-0.5,51.7,0.3"

# Get route details
gtfs-bods query ./gtfs.db --route-id "12345"

# Filter by agency
gtfs-bods query ./gtfs.db --routes --agency-key london-transport

Options:

  • -r, --report - Generate comprehensive report
  • -a, --agencies - List all agencies
  • -R, --routes - List all routes
  • -s, --stops - List all stops
  • -k, --agency-key <key> - Filter by agency key
  • --route-id <id> - Get details for specific route
  • --area <bounds> - Find stops in area (format: minLat,minLon,maxLat,maxLon)

info - File Information

Display information about GTFS files or databases:

gtfs-bods info <file>

Examples:

# Analyze GTFS zip file
gtfs-bods info ./data.zip

# Analyze SQLite database
gtfs-bods info ./gtfs.db

🌟 Features

  • 🚌 GTFS Processing: Full support for GTFS specification
  • 🗄️ SQLite Storage: Efficient database storage and querying
  • 🔍 Data Analysis: Comprehensive reporting and statistics
  • 🗺️ Geographic Queries: Find stops within geographic boundaries
  • 📤 Data Export: Export processed data back to GTFS format
  • 🎨 Colored Output: Beautiful terminal output with chalk
  • ⚡ Fast Performance: Optimized for large datasets
  • 🛠️ TypeScript: Fully typed with modern ES modules

📊 Example Workflows

Basic Data Processing

# 1. Download GTFS data from UK BODS
wget https://data.bus-data.dft.gov.uk/timetable/download/gtfs-file/all/ -O uk-bods.zip

# 2. Import into database
gtfs-bods import uk-bods.zip uk-transit.db

# 3. Generate report
gtfs-bods query uk-transit.db --report

# 4. Export for use in other tools
gtfs-bods export uk-transit.db ./gtfs-export/

Transit Analysis

# Analyze London area transit
gtfs-bods query ./uk-transit.db --area "51.28,-0.51,51.69,0.33" > london-stops.txt

# Find all bus routes
gtfs-bods query ./uk-transit.db --routes | grep -i "bus" > bus-routes.txt

# Get agency information
gtfs-bods query ./uk-transit.db --agencies

Data Migration

# Convert old GTFS data to new format
gtfs-bods import ./old-data.zip ./temp.db
gtfs-bods export ./temp.db ./new-gtfs-format/

📁 Database Schema

The SQLite database follows the GTFS specification:

  • agencies - Transit agencies and operators
  • routes - Bus/transit routes
  • stops - Bus stops and stations
  • trips - Individual trip instances
  • stop_times - Detailed timetable data
  • calendar - Service periods and schedules
  • shapes - Route geometry for mapping (if available)

🛠️ Development

Local Development

# Clone repository
git clone https://github.com/DRFR0ST/gtfs-bods.git
cd gtfs-bods

# Install dependencies
npm install

# Build project
npm run build

# Test CLI locally
npm run dev:cli -- import ./test.zip ./test.db

Scripts

| Command | Description | |---------|-------------| | npm run build | Compile TypeScript to JavaScript | | npm run dev:cli | Run CLI in development mode | | npm start | Build and run main application | | npm run prepublishOnly | Pre-publish build step |

🚀 API Usage

You can also use the tool programmatically:

import { importGtfs, exportGtfs } from 'gtfs';
import { GTFSQueries } from 'gtfs-bods/dist/queries.js';

// Import GTFS data
const config = {
  agencies: [
    {
      agency_key: 'my-transit',
      path: './data.zip'
    }
  ],
  sqlitePath: './transit.db'
};

await importGtfs(config);

// Query data
const agencies = await GTFSQueries.getAllAgencies();
const routes = await GTFSQueries.getAllRoutes();

🔧 Requirements

  • Node.js 18.0.0 or higher
  • npm 6.0.0 or higher

📦 Data Sources

This tool works with GTFS data from various sources:

  • UK Bus Open Data Service (BODS): https://data.bus-data.dft.gov.uk/
  • Any GTFS-compliant data source
  • Transit agencies worldwide

🤝 Contributing

  1. Fork the repository
  2. Create a feature branch: git checkout -b feature/amazing-feature
  3. Commit changes: git commit -m 'Add amazing feature'
  4. Push to branch: git push origin feature/amazing-feature
  5. Open a Pull Request

📄 License

This project is licensed under the ISC License - see the LICENSE file for details.

🆘 Support

🙏 Acknowledgments


Made with ❤️ for the UK transit community