Rail Station Information

Rail line and station information, including locations, fares, times, and parking.

XML - 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.

Try it

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

string
Subscription key which provides access to this API. Found in your Profile.

Request body

Response 200

Default response code.



<StationsResp
    xmlns="http://www.wmata.com"
    xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
    <Stations>
        <Station>
            <Address>
                <City>Rockville</City>
                <State>MD</State>
                <Street>15903 Somerville Drive</Street>
                <Zip>20855</Zip>
            </Address>
            <Code>A15</Code>
            <Lat>39.1199273249</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.1646273343</Lon>
            <Name>Shady Grove</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Rockville</City>
                <State>MD</State>
                <Street>251 Hungerford Drive</Street>
                <Zip>20850</Zip>
            </Address>
            <Code>A14</Code>
            <Lat>39.0843216075</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.1461253392</Lon>
            <Name>Rockville</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Rockville</City>
                <State>MD</State>
                <Street>1600 Chapman Avenue</Street>
                <Zip>20852</Zip>
            </Address>
            <Code>A13</Code>
            <Lat>39.0624676517</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.1208179517</Lon>
            <Name>Twinbrook</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Rockville</City>
                <State>MD</State>
                <Street>5500 Marinelli Road</Street>
                <Zip>20852</Zip>
            </Address>
            <Code>A12</Code>
            <Lat>39.0481513573</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.112829859</Lon>
            <Name>White Flint</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Bethesda</City>
                <State>MD</State>
                <Street>10300 Rockville Pike</Street>
                <Zip>20852</Zip>
            </Address>
            <Code>A11</Code>
            <Lat>39.02926895</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.10384972</Lon>
            <Name>Grosvenor</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Bethesda</City>
                <State>MD</State>
                <Street>8810 Rockville Pike</Street>
                <Zip>20814</Zip>
            </Address>
            <Code>A10</Code>
            <Lat>39.0000564843</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0969522905</Lon>
            <Name>Medical Center</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Bethesda</City>
                <State>MD</State>
                <Street>7450 Wisconsin Avenue</Street>
                <Zip>20814</Zip>
            </Address>
            <Code>A09</Code>
            <Lat>38.9843936603</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0941291922</Lon>
            <Name>Bethesda</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>5337 Wisconsin Avenue NW</Street>
                <Zip>20015</Zip>
            </Address>
            <Code>A08</Code>
            <Lat>38.9594838736</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.084995805</Lon>
            <Name>Friendship Heights</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>4501 Wisconsin Avenue NW</Street>
                <Zip>20016</Zip>
            </Address>
            <Code>A07</Code>
            <Lat>38.9488514351</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0795873255</Lon>
            <Name>Tenleytown</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>4200 Connecticut Avenue NW</Street>
                <Zip>20008</Zip>
            </Address>
            <Code>A06</Code>
            <Lat>38.9432652883</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0629861805</Lon>
            <Name>Van Ness UDC</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>3599 Connecticut Avenue NW</Street>
                <Zip>20008</Zip>
            </Address>
            <Code>A05</Code>
            <Lat>38.9347628908</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0580425191</Lon>
            <Name>Cleveland Park</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>2700 Connecticut Ave., NW</Street>
                <Zip>20008</Zip>
            </Address>
            <Code>A04</Code>
            <Lat>38.9250851371</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0524180207</Lon>
            <Name>Woodley Park Zoo</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>1525 20th St. NW</Street>
                <Zip>20036</Zip>
            </Address>
            <Code>A03</Code>
            <Lat>38.9095980575</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0434143597</Lon>
            <Name>Dupont Circle</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>1001 Connecticut Avenue NW</Street>
                <Zip>20036</Zip>
            </Address>
            <Code>A02</Code>
            <Lat>38.9032019462</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0397008272</Lon>
            <Name>Farragut North</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>607 13th St. NW</Street>
                <Zip>20005</Zip>
            </Address>
            <Code>A01</Code>
            <Lat>38.8983144732</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0280779971</Lon>
            <Name>Metro Center</Name>
            <StationTogether1>C01</StationTogether1>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>630 H St. NW</Street>
                <Zip>20001</Zip>
            </Address>
            <Code>B01</Code>
            <Lat>38.8983168097</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0219153904</Lon>
            <Name>Gallery Place</Name>
            <StationTogether1>F01</StationTogether1>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>450 F Street NW</Street>
                <Zip>20001</Zip>
            </Address>
            <Code>B02</Code>
            <Lat>38.8960903176</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0166389566</Lon>
            <Name>Judiciary Square</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>701 First St. NE</Street>
                <Zip>20002</Zip>
            </Address>
            <Code>B03</Code>
            <Lat>38.8977660392</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0074142921</Lon>
            <Name>Union Station</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>200 Florida Ave N.E.</Street>
                <Zip>20002</Zip>
            </Address>
            <Code>B35</Code>
            <Lat>38.9070162121</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0030204472</Lon>
            <Name>New York Avenue</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>919 Rhode Island Avenue NE</Street>
                <Zip>20018</Zip>
            </Address>
            <Code>B04</Code>
            <Lat>38.9210596891</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-76.9959369166</Lon>
            <Name>Rhode Island Avenue</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>801 Michigan Avenue NE</Street>
                <Zip>20017</Zip>
            </Address>
            <Code>B05</Code>
            <Lat>38.9332109913</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-76.9945342851</Lon>
            <Name>Brookland</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>550 Galloway Street NE</Street>
                <Zip>20011</Zip>
            </Address>
            <Code>B06</Code>
            <Lat>38.9518467675</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0022030768</Lon>
            <Name>Fort Totten</Name>
            <StationTogether1>E06</StationTogether1>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Washington</City>
                <State>DC</State>
                <Street>327 Cedar Street NW</Street>
                <Zip>20012</Zip>
            </Address>
            <Code>B07</Code>
            <Lat>38.976078531</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0181766987</Lon>
            <Name>Takoma</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Silver Spring</City>
                <State>MD</State>
                <Street>8400 Colesville Road</Street>
                <Zip>20910</Zip>
            </Address>
            <Code>B08</Code>
            <Lat>38.9939493747</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0310178268</Lon>
            <Name>Silver Spring</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Forest Glen</City>
                <State>MD</State>
                <Street>9730 Georgia Avenue</Street>
                <Zip>20910</Zip>
            </Address>
            <Code>B09</Code>
            <Lat>39.0149542752</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0429165548</Lon>
            <Name>Forest Glen</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Silver Spring</City>
                <State>MD</State>
                <Street>11171 Georgia Avenue</Street>
                <Zip>20902</Zip>
            </Address>
            <Code>B10</Code>
            <Lat>39.0375271436</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0501070535</Lon>
            <Name>Wheaton</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
        <Station>
            <Address>
                <City>Silver Spring</City>
                <State>MD</State>
                <Street>12501 Georgia Avenue</Street>
                <Zip>20906</Zip>
            </Address>
            <Code>B11</Code>
            <Lat>39.0617837655</Lat>
            <LineCode1>RD</LineCode1>
            <LineCode2 i:nil="true"/>
            <LineCode3 i:nil="true"/>
            <LineCode4 i:nil="true"/>
            <Lon>-77.0535573593</Lon>
            <Name>Glenmont</Name>
            <StationTogether1/>
            <StationTogether2/>
        </Station>
    </Stations>
</StationsResp>

Code samples

@ECHO OFF

curl -v -X GET "https://api.wmata.com/Rail.svc/Stations?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/Stations?" + 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/Stations");

            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/Stations?" + $.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/Stations";
    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/Stations');
$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/Stations?%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/Stations?%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/Stations')

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