Rail Station Information
Rail line and station information, including locations, fares, times, and parking.
JSON - Station List
Description
Returns a list of station location and address information based on a given LineCode. Omit the LineCode to return all stations. The response is an array of objects identical to those returned in the Station Information method.
Response Elements
Element | Description |
---|---|
Stations | Array containing station information (Station). |
Address | Structure describing address information. |
Code | Station code. Repeated from input. |
Lat | Latitude. |
LineCode1 | Two-letter abbreviation for the line (e.g.: RD, BL, YL, OR, GR, or SV) served by this station. |
LineCode2 | Additional line served by this station. This is often the case when stations have multiple platforms (e.g.: Gallery Place, Fort Totten, L'Enfant Plaza, and Metro Center). |
LineCode3 | Similar to function as LineCodeX. |
LineCode4 | Similar to function as LineCodeX. Currently not in use. |
Lon | Longitude. |
Name | Station name. |
StationTogether1 | For stations with multiple platforms (e.g.: Gallery Place, Fort Totten, L'Enfant Plaza, and Metro Center), the additional StationCode will be listed here. |
StationTogether2 | Similar in function to StationTogether2. Currently not in use. |
City | City. |
State | State (abbreviated). |
Street | Street address (for GPS use). |
Zip | Zip code. |
Request URL
Request parameters
(optional)
string
Two-letter line code abbreviation:
- RD - Red
- YL - Yellow
- GR - Green
- BL - Blue
- OR - Orange
- SV - Silver
Request headers
Request body
Response 200
Default response code.
{
"Stations": [
{
"Address": {
"City": "Rockville",
"State": "MD",
"Street": "15903 Somerville Drive",
"Zip": "20855"
},
"Code": "A15",
"Lat": 39.1199273249,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.1646273343,
"Name": "Shady Grove",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Rockville",
"State": "MD",
"Street": "251 Hungerford Drive",
"Zip": "20850"
},
"Code": "A14",
"Lat": 39.0843216075,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.1461253392,
"Name": "Rockville",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Rockville",
"State": "MD",
"Street": "1600 Chapman Avenue",
"Zip": "20852"
},
"Code": "A13",
"Lat": 39.0624676517,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.1208179517,
"Name": "Twinbrook",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Rockville",
"State": "MD",
"Street": "5500 Marinelli Road",
"Zip": "20852"
},
"Code": "A12",
"Lat": 39.0481513573,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.112829859,
"Name": "White Flint",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Bethesda",
"State": "MD",
"Street": "10300 Rockville Pike",
"Zip": "20852"
},
"Code": "A11",
"Lat": 39.02926895,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.10384972,
"Name": "Grosvenor",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Bethesda",
"State": "MD",
"Street": "8810 Rockville Pike",
"Zip": "20814"
},
"Code": "A10",
"Lat": 39.0000564843,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0969522905,
"Name": "Medical Center",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Bethesda",
"State": "MD",
"Street": "7450 Wisconsin Avenue",
"Zip": "20814"
},
"Code": "A09",
"Lat": 38.9843936603,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0941291922,
"Name": "Bethesda",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "5337 Wisconsin Avenue NW",
"Zip": "20015"
},
"Code": "A08",
"Lat": 38.9594838736,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.084995805,
"Name": "Friendship Heights",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "4501 Wisconsin Avenue NW",
"Zip": "20016"
},
"Code": "A07",
"Lat": 38.9488514351,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0795873255,
"Name": "Tenleytown",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "4200 Connecticut Avenue NW",
"Zip": "20008"
},
"Code": "A06",
"Lat": 38.9432652883,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0629861805,
"Name": "Van Ness UDC",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "3599 Connecticut Avenue NW",
"Zip": "20008"
},
"Code": "A05",
"Lat": 38.9347628908,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0580425191,
"Name": "Cleveland Park",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "2700 Connecticut Ave., NW",
"Zip": "20008"
},
"Code": "A04",
"Lat": 38.9250851371,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0524180207,
"Name": "Woodley Park Zoo",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "1525 20th St. NW",
"Zip": "20036"
},
"Code": "A03",
"Lat": 38.9095980575,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0434143597,
"Name": "Dupont Circle",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "1001 Connecticut Avenue NW",
"Zip": "20036"
},
"Code": "A02",
"Lat": 38.9032019462,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0397008272,
"Name": "Farragut North",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "607 13th St. NW",
"Zip": "20005"
},
"Code": "A01",
"Lat": 38.8983144732,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0280779971,
"Name": "Metro Center",
"StationTogether1": "C01",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "630 H St. NW",
"Zip": "20001"
},
"Code": "B01",
"Lat": 38.8983168097,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0219153904,
"Name": "Gallery Place",
"StationTogether1": "F01",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "450 F Street NW",
"Zip": "20001"
},
"Code": "B02",
"Lat": 38.8960903176,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0166389566,
"Name": "Judiciary Square",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "701 First St. NE",
"Zip": "20002"
},
"Code": "B03",
"Lat": 38.8977660392,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0074142921,
"Name": "Union Station",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "200 Florida Ave N.E.",
"Zip": "20002"
},
"Code": "B35",
"Lat": 38.9070162121,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0030204472,
"Name": "New York Avenue",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "919 Rhode Island Avenue NE",
"Zip": "20018"
},
"Code": "B04",
"Lat": 38.9210596891,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -76.9959369166,
"Name": "Rhode Island Avenue",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "801 Michigan Avenue NE",
"Zip": "20017"
},
"Code": "B05",
"Lat": 38.9332109913,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -76.9945342851,
"Name": "Brookland",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "550 Galloway Street NE",
"Zip": "20011"
},
"Code": "B06",
"Lat": 38.9518467675,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0022030768,
"Name": "Fort Totten",
"StationTogether1": "E06",
"StationTogether2": ""
},
{
"Address": {
"City": "Washington",
"State": "DC",
"Street": "327 Cedar Street NW",
"Zip": "20012"
},
"Code": "B07",
"Lat": 38.976078531,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0181766987,
"Name": "Takoma",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Silver Spring",
"State": "MD",
"Street": "8400 Colesville Road",
"Zip": "20910"
},
"Code": "B08",
"Lat": 38.9939493747,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0310178268,
"Name": "Silver Spring",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Forest Glen",
"State": "MD",
"Street": "9730 Georgia Avenue",
"Zip": "20910"
},
"Code": "B09",
"Lat": 39.0149542752,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0429165548,
"Name": "Forest Glen",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Silver Spring",
"State": "MD",
"Street": "11171 Georgia Avenue",
"Zip": "20902"
},
"Code": "B10",
"Lat": 39.0375271436,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0501070535,
"Name": "Wheaton",
"StationTogether1": "",
"StationTogether2": ""
},
{
"Address": {
"City": "Silver Spring",
"State": "MD",
"Street": "12501 Georgia Avenue",
"Zip": "20906"
},
"Code": "B11",
"Lat": 39.0617837655,
"LineCode1": "RD",
"LineCode2": null,
"LineCode3": null,
"LineCode4": null,
"Lon": -77.0535573593,
"Name": "Glenmont",
"StationTogether1": "",
"StationTogether2": ""
}
]
}
Code samples
@ECHO OFF
curl -v -X GET "https://api.wmata.com/Rail.svc/json/jStations?LineCode={string}"
-H "api_key: {subscription key}"
--data-ascii "{body}"
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("api_key", "{subscription key}");
// Request parameters
queryString["LineCode"] = "{string}";
var uri = "https://api.wmata.com/Rail.svc/json/jStations?" + queryString;
var response = await client.GetAsync(uri);
}
}
}
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample
{
public static void main(String[] args)
{
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://api.wmata.com/Rail.svc/json/jStations");
builder.setParameter("LineCode", "{string}");
URI uri = builder.build();
HttpGet request = new HttpGet(uri);
request.setHeader("api_key", "{subscription key}");
// Request body
StringEntity reqEntity = new StringEntity("{body}");
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null)
{
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
"api_key": "{subscription key}",
// Request parameters
"LineCode": "{string}",
};
$.ajax({
url: "https://api.wmata.com/Rail.svc/json/jStations?" + $.param(params),
type: "GET",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* path = @"https://api.wmata.com/Rail.svc/json/jStations";
NSArray* array = @[
// Request parameters
@"entities=true",
@"LineCode={string}",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"GET"];
// Request headers
[_request setValue:@"{subscription key}" forHTTPHeaderField:@"api_key"];
// Request body
[_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if (nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if (nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://api.wmata.com/Rail.svc/json/jStations');
$url = $request->getUrl();
$headers = array(
// Request headers
'api_key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'LineCode' => '{string}',
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_GET);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Request headers
'api_key': '{subscription key}',
}
params = urllib.urlencode({
# Request parameters
'LineCode': '{string}',
})
try:
conn = httplib.HTTPSConnection('api.wmata.com')
conn.request("GET", "/Rail.svc/json/jStations?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'api_key': '{subscription key}',
}
params = urllib.parse.urlencode({
# Request parameters
'LineCode': '{string}',
})
try:
conn = http.client.HTTPSConnection('api.wmata.com')
conn.request("GET", "/Rail.svc/json/jStations?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://api.wmata.com/Rail.svc/json/jStations')
query = URI.encode_www_form({
# Request parameters
'LineCode' => '{string}'
})
if uri.query && uri.query.length > 0
uri.query += '&' + query
else
uri.query = query
end
request = Net::HTTP::Get.new(uri.request_uri)
# Request headers
request['api_key'] = '{subscription key}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body