API Documentation

Authentication

All requests must include your API key in the header.

headers: { 'x-api-key': 'mta_live_...' }

Example Request

cURL

curl "https://api.mta-json.com/?line=G&stopId=G22" \ -H "x-api-key: mta_live_YOUR_KEY_HERE"

JavaScript (Fetch)

const res = await fetch("https://api.mta-json.com/?line=G&stopId=G22", { headers: { "x-api-key": "mta_live_YOUR_KEY_HERE" } }); const data = await res.json();

Query Parameters

Param Type Description
line string The subway line to fetch. Options: G, L, 1, 7, etc. Defaults to G.
stopId string The GTFS Stop ID to filter by (e.g., G22). Defaults to Nassau Av (G22).

Response Object

Returns simple arrays of arrival times (in minutes from now).

{
  "station": "Nassau Av",
  "line": "G",
  "timestamp": 1706650000,
  "northbound": [2, 14, 21],
  "southbound": [0, 8, 15]
}

Errors