Transport for New York City

Transport for New York City

Accessing MTA Data with the DataMine API

The DataMine API allows developers to access real-time data from the New York City Metropolitan Transportation Authority (MTA). This API provides a wealth of information on things like train schedules, delays, and service changes, as well as real-time data on bus and train locations.

In this blog post, we’ll go over some of the basics of using the DataMine API and provide some example code in JavaScript.

Getting Started

To get started, you’ll need to sign up for an API key, which you can do at Once you’ve got your key, you can start making requests to the API.

Making Requests

All requests to the DataMine API are made via HTTP GET requests. The base URL for the API is, and all requests require an API key parameter, which should be passed in the query string of the request URL.

For example, to get real-time data on the 1 train, you would make a GET request to the following URL:

This request would return a JSON object containing real-time data on the 1 train, including its current location, speed, and direction.

Example Code

Here’s some example code in JavaScript to get real-time data on the 1 train using the DataMine API:

const apiKey = 'YOUR_API_KEY';
const feedId = 1;

const url = `${apiKey}&feed_id=${feedId}`;

    .then((response) => response.json())
    .then((data) => {
        // Do something with the data...
    .catch((error) => console.error(error));

In this example, we’re using the fetch() method to make a GET request to the DataMine API. We pass in our API key and the feed ID for the 1 train, and then parse the response data as JSON.


The DataMine API provides a powerful tool for developers looking to incorporate real-time data from the MTA into their applications. With a little bit of JavaScript code, you can access a wealth of information on train and bus schedules, service changes, and real-time location data.

If you’re interested in learning more, be sure to check out the official documentation for the DataMine API. Happy coding!