Bus Route and Stop Methods

Bus stop information, route and schedule data, and bus positions.

JSON - Stop Search

Description

Returns a list of nearby bus stops based on latitude, longitude, and radius. Omit all parameters to retrieve a list of all stops.

Response Elements

Element Description
Stops Array containing stop information (Stop).
Lat Latitude.
Lon Longitude.
Name Stop name. May be slightly different from what is spoken or displayed in the bus.
Routes String array of route variants which provide service at this stop. Note that these are not date-specific; any route variant which stops at this stop on any day will be listed.
StopID 7-digit regional ID which can be used in various bus-related methods. If unavailable, the StopID will be 0 or NULL.

Try it

Request URL

Request parameters

(optional)
number

Center point Latitude, required if Longitude and Radius are specified.

(optional)
number

Center point Longitude, required if Latitude and Radius are specified.

(optional)
number

Radius (meters) to include in the search area, required if Latitude and Longitude are specified.

Request headers

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

Request body

Response 200

Default response code.

{
    "Stops": [
        {
            "Lat": 38.878356,
            "Lon": -76.990378,
            "Name": "K ST + POTOMAC AVE",
            "Routes": [
                "V7",
                "V7c",
                "V7cv1",
                "V7v1",
                "V7v2",
                "V8",
                "V9"
            ],
            "StopID": "1000533"
        },
        {
            "Lat": 38.879041,
            "Lon": -76.988528,
            "Name": "POTOMAC AVE + 13TH ST",
            "Routes": [
                "V7",
                "V7c",
                "V7cv1",
                "V7v1",
                "V7v2",
                "V8",
                "V9"
            ],
            "StopID": "1000544"
        },
        {
            "Lat": 38.879347,
            "Lon": -76.991248,
            "Name": "I ST + 11TH ST",
            "Routes": [
                "V7",
                "V7c",
                "V7cv1",
                "V7cv2",
                "V8",
                "V9"
            ],
            "StopID": "1000550"
        },
        {
            "Lat": 38.879416,
            "Lon": -76.98795,
            "Name": "POTOMAC AVE + 13TH ST",
            "Routes": [
                "V7",
                "V7c",
                "V7cv1",
                "V7cv2",
                "V8",
                "V9"
            ],
            "StopID": "1003487"
        },
        {
            "Lat": 38.877237,
            "Lon": -76.991432,
            "Name": "11TH ST SE + M ST SE",
            "Routes": [
                "V5",
                "V7",
                "V7c",
                "V7cv1",
                "V7v1",
                "V7v2",
                "V8",
                "V9"
            ],
            "StopID": "1000521"
        },
        {
            "Lat": 38.879344,
            "Lon": -76.992506,
            "Name": "I ST + 10TH ST",
            "Routes": [
                "V7",
                "V7c",
                "V7cv1",
                "V7cv2",
                "V8",
                "V9"
            ],
            "StopID": "1000554"
        },
        {
            "Lat": 38.876583,
            "Lon": -76.992114,
            "Name": "M ST + 10 TH ST",
            "Routes": [
                "90",
                "92",
                "92c",
                "93",
                "93cv1",
                "A42",
                "A42v1",
                "A46",
                "A46v1",
                "A48",
                "A48v1",
                "P6"
            ],
            "StopID": "1003285"
        },
        {
            "Lat": 38.876379,
            "Lon": -76.991992,
            "Name": "M ST + 11TH ST SE",
            "Routes": [
                "90",
                "92",
                "93",
                "93v2",
                "A42",
                "A42v1",
                "A46",
                "A48",
                "A9",
                "P6",
                "V5"
            ],
            "StopID": "1000499"
        },
        {
            "Lat": 38.88136,
            "Lon": -76.988525,
            "Name": "PENNSYLVANIA AVE SE + 13TH ST SE",
            "Routes": [
                "30N",
                "30S",
                "32",
                "32v1",
                "34",
                "36"
            ],
            "StopID": "1000587"
        },
        {
            "Lat": 38.880028,
            "Lon": -76.985716,
            "Name": "POTOMAC AVE (S RDWY) + 14TH ST",
            "Routes": [
                "V7",
                "V7c",
                "V7cv1",
                "V7v1",
                "V7v2",
                "V8",
                "V9"
            ],
            "StopID": "1000565"
        },
        {
            "Lat": 38.880135,
            "Lon": -76.985501,
            "Name": "PENNSYLVANIA AVE SE + POTOMAC AVE S",
            "Routes": [
                "30N",
                "30S",
                "32",
                "32v1",
                "34",
                "36",
                "39",
                "K11",
                "M6"
            ],
            "StopID": "1003185"
        },
        {
            "Lat": 38.87935,
            "Lon": -76.994258,
            "Name": "I ST + BET 8TH & 9TH STS",
            "Routes": [
                "V7",
                "V7c",
                "V7cv1",
                "V7cv2",
                "V8",
                "V9"
            ],
            "StopID": "1000551"
        },
        {
            "Lat": 38.881628,
            "Lon": -76.988173,
            "Name": "PENNSYLVANIA AVE SE + 13TH ST SE",
            "Routes": [
                "30N",
                "30S",
                "32",
                "34",
                "36",
                "A11"
            ],
            "StopID": "1000593"
        },
        {
            "Lat": 38.880519,
            "Lon": -76.985482,
            "Name": "PENNSYLVANIA AVE SE + POTOMAC AVE S",
            "Routes": [
                "30N",
                "30S",
                "32",
                "34",
                "36",
                "39",
                "A11"
            ],
            "StopID": "1000576"
        },
        {
            "Lat": 38.880648,
            "Lon": -76.985378,
            "Name": "POTOMAC AVE + 14TH ST SE",
            "Routes": [
                "J13",
                "K11",
                "M6"
            ],
            "StopID": "1000578"
        },
        {
            "Lat": 38.877849,
            "Lon": -76.994875,
            "Name": "8TH ST SE + L ST SE",
            "Routes": [
                "90",
                "90v1",
                "92",
                "92c",
                "93",
                "93cv1"
            ],
            "StopID": "1000527"
        },
        {
            "Lat": 38.880216,
            "Lon": -76.984727,
            "Name": "PENNSYLVANIA AVE SE + POTOMAC AVE S",
            "Routes": [
                "B2",
                "B2c",
                "B2vS2",
                "V7",
                "V7c",
                "V7cv1",
                "V7cv2",
                "V8",
                "V9"
            ],
            "StopID": "1002965"
        },
        {
            "Lat": 38.877254,
            "Lon": -76.995082,
            "Name": "8TH ST SE + L ST SE",
            "Routes": [
                "90",
                "92",
                "93",
                "93v2",
                "V5",
                "V7",
                "V7c",
                "V7cv1",
                "V7cv2",
                "V8",
                "V9"
            ],
            "StopID": "1003755"
        },
        {
            "Lat": 38.876616,
            "Lon": -76.994764,
            "Name": "M ST + 8TH ST SE",
            "Routes": [
                "90",
                "92",
                "92c",
                "93",
                "93cv1",
                "A42",
                "A42v1",
                "A46",
                "A46v1",
                "A48",
                "A48v1",
                "A9",
                "P6"
            ],
            "StopID": "1000514"
        },
        {
            "Lat": 38.879444,
            "Lon": -76.983804,
            "Name": "PENNSYLVANIA AVE SE + 15TH ST SE",
            "Routes": [
                "30N",
                "30S",
                "32",
                "32v1",
                "34",
                "36",
                "K11",
                "M6",
                "V7",
                "V7c",
                "V7cv1",
                "V7v1",
                "V7v2",
                "V8",
                "V9"
            ],
            "StopID": "1000559"
        },
        {
            "Lat": 38.879911,
            "Lon": -76.983766,
            "Name": "15TH ST SE + PENNSYLVANIA AVE SE",
            "Routes": [
                "B2",
                "B2v1",
                "B2vS1",
                "B2vS2"
            ],
            "StopID": "1000571"
        },
        {
            "Lat": 38.882743,
            "Lon": -76.990934,
            "Name": "PENNSYLVANIA AVE SE + E ST SE",
            "Routes": [
                "30N",
                "30S",
                "32",
                "34",
                "36",
                "A11"
            ],
            "StopID": "1000611"
        },
        {
            "Lat": 38.881127,
            "Lon": -76.994876,
            "Name": "8TH ST + G ST",
            "Routes": [
                "90",
                "90v1",
                "92",
                "93"
            ],
            "StopID": "1000585"
        },
        {
            "Lat": 38.882922,
            "Lon": -76.99,
            "Name": "E STREET SE + 12TH ST SE",
            "Routes": [
                "C40"
            ],
            "StopID": "1003600"
        },
        {
            "Lat": 38.88095,
            "Lon": -76.983833,
            "Name": "POTOMAC AVE SE + 15TH ST SE",
            "Routes": [
                "B2",
                "B2c",
                "B2vS2"
            ],
            "StopID": "1000582"
        }
    ]
}

Code samples

@ECHO OFF

curl -v -X GET "https://api.wmata.com/Bus.svc/json/jStops?Lat={number}&Lon={number}&Radius={number}"
-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["Lat"] = "{number}";
            queryString["Lon"] = "{number}";
            queryString["Radius"] = "{number}";
            var uri = "https://api.wmata.com/Bus.svc/json/jStops?" + 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/Bus.svc/json/jStops");

            builder.setParameter("Lat", "{number}");
            builder.setParameter("Lon", "{number}");
            builder.setParameter("Radius", "{number}");

            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
            "Lat": "{number}",
            "Lon": "{number}",
            "Radius": "{number}",
        };
      
        $.ajax({
            url: "https://api.wmata.com/Bus.svc/json/jStops?" + $.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/Bus.svc/json/jStops";
    NSArray* array = @[
                         // Request parameters
                         @"entities=true",
                         @"Lat={number}",
                         @"Lon={number}",
                         @"Radius={number}",
                      ];
    
    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/Bus.svc/json/jStops');
$url = $request->getUrl();

$headers = array(
    // Request headers
    'api_key' => '{subscription key}',
);

$request->setHeader($headers);

$parameters = array(
    // Request parameters
    'Lat' => '{number}',
    'Lon' => '{number}',
    'Radius' => '{number}',
);

$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
    'Lat': '{number}',
    'Lon': '{number}',
    'Radius': '{number}',
})

try:
    conn = httplib.HTTPSConnection('api.wmata.com')
    conn.request("GET", "/Bus.svc/json/jStops?%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
    'Lat': '{number}',
    'Lon': '{number}',
    'Radius': '{number}',
})

try:
    conn = http.client.HTTPSConnection('api.wmata.com')
    conn.request("GET", "/Bus.svc/json/jStops?%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/Bus.svc/json/jStops')

query = URI.encode_www_form({
    # Request parameters
    'Lat' => '{number}',
    'Lon' => '{number}',
    'Radius' => '{number}'
})

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