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

@mtd.org/developer-api-client

v3.0.1

Published

Typescript types for MTD's Developer API

Readme

@mtd.org/developer-api-client

Type-safe API client for the MTD Developer API.

This package provides a fully type-safe HTTP client for the Champaign-Urbana Mass Transit District (MTD) Developer API, built on openapi-fetch with types generated from the official OpenAPI specification.

Features

  • Fully Type-Safe: Complete TypeScript support with autocomplete and compile-time validation
  • Lightweight: Minimal dependencies, tree-shakeable
  • Spec-Driven: Generated directly from the official OpenAPI spec
  • Modern: Built on native fetch API
  • Framework Agnostic: Works anywhere JavaScript runs

Installation

npm install @mtd.org/developer-api-client
pnpm add @mtd.org/developer-api-client

Quick Start

import createClient from '@mtd.org/developer-api-client';

// Create a client with your API key
const client = createMtdApiClient({
	apiKey: "your-api-key",
});

// Error here contains any transport errors.
const {
    data, // only present if 2XX response
    error: httpError // only present if 4XX or 5XX response
} = await client.GET("/stops/{stopId}/departures", {
	params: {
		path: { stopId: "IT" },
	},
});

if (httpError) {
	console.error("API Error:", httpError);
    return;
}

if (!data) {
	console.log("No data received");
	return;
}

const { result, error: apiError } = data;

// Non-http errors returned by the MTD API
if (apiError) {
	console.error("API returned an error:", apiError);
	return;
}

if (!result || result.length === 0) {
	console.log("No departures found for this stop.");
	return;
}

// data is fully typed!
for (const departure of result) {
	console.log("Departure:", {
		headsign: departure.headsign,
		expected_mins: departure.estimatedDeparture,
	});
}

API Reference

Creating a Client

import createClient from '@mtd.org/developer-api-client';

const client = createClient({
	apiKey: 'your-api-key',
	// Optional: override base URL
	// baseUrl: 'url override'
});

Making Requests

All API methods are fully typed based on the OpenAPI specification. Path and query params are specified as objects inside params.

const { data, error } = client.GET("/shapes/{shapeId}", {
	params: {
		query: {
			polyline: true,
		},
		path: {
			shapeId: "12345",
		},
	},
});

Error Handling

The client returns both data and error. Always check for errors:

const { data, error } = await client.GET('/GetRoutes');

if (error) {
	// Error is typed based on the API spec
	console.error('Status:', error.status);
	console.error('Message:', error.message);
	return;
}

// Safe to use data here
console.log(data.routes);

TypeScript Support

The client provides full TypeScript support out of the box:

import type { paths, components } from '@mtd.org/developer-api-types';

// Use types from the spec
type Route = components['schemas']['Route'];
type Vehicle = components['schemas']['Vehicle'];

// All requests and responses are typed
const client = createClient({ apiKey: 'key' });
const response = await client.GET('/GetRoutes'); // response is typed!

Related Packages

Getting Your API Key

To use this client, you'll need an MTD Developer API key:

  1. Visit mtd.dev
  2. Sign up for a free developer account
  3. Create an API key in your dashboard
  4. Use the key with this client

Documentation

License

Apache-2.0

Support

Contributing

This package is generated from the OpenAPI specification. For bugs or feature requests, please open an issue on the main repository.