Bus Route and Stop Methods
Bus stop information, route and schedule data, and bus positions.
XML - 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. |
Request URL
Request parameters
(optional)
string
Center point Latitude, required if Longitude and Radius are specified.
(optional)
string
Center point Longitude, required if Latitude and Radius are specified.
(optional)
string
Radius (feet) to include in the search area, required if Latitude and Longitude are specified.
Request headers
Request body
Response 200
Default response code.
<StopsResp
xmlns="http://www.wmata.com"
xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
<Stops>
<Stop>
<Lat>38.878356</Lat>
<Lon>-76.990378</Lon>
<Name>K ST + POTOMAC AVE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7v1</a:string>
<a:string>V7v2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1000533</StopID>
</Stop>
<Stop>
<Lat>38.879041</Lat>
<Lon>-76.988528</Lon>
<Name>POTOMAC AVE + 13TH ST</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7v1</a:string>
<a:string>V7v2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1000544</StopID>
</Stop>
<Stop>
<Lat>38.879347</Lat>
<Lon>-76.991248</Lon>
<Name>I ST + 11TH ST</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7cv2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1000550</StopID>
</Stop>
<Stop>
<Lat>38.879416</Lat>
<Lon>-76.98795</Lon>
<Name>POTOMAC AVE + 13TH ST</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7cv2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1003487</StopID>
</Stop>
<Stop>
<Lat>38.877237</Lat>
<Lon>-76.991432</Lon>
<Name>11TH ST SE + M ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>V5</a:string>
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7v1</a:string>
<a:string>V7v2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1000521</StopID>
</Stop>
<Stop>
<Lat>38.879344</Lat>
<Lon>-76.992506</Lon>
<Name>I ST + 10TH ST</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7cv2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1000554</StopID>
</Stop>
<Stop>
<Lat>38.876583</Lat>
<Lon>-76.992114</Lon>
<Name>M ST + 10 TH ST</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>90</a:string>
<a:string>92</a:string>
<a:string>92c</a:string>
<a:string>93</a:string>
<a:string>93cv1</a:string>
<a:string>A42</a:string>
<a:string>A42v1</a:string>
<a:string>A46</a:string>
<a:string>A46v1</a:string>
<a:string>A48</a:string>
<a:string>A48v1</a:string>
<a:string>P6</a:string>
</Routes>
<StopID>1003285</StopID>
</Stop>
<Stop>
<Lat>38.876379</Lat>
<Lon>-76.991992</Lon>
<Name>M ST + 11TH ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>90</a:string>
<a:string>92</a:string>
<a:string>93</a:string>
<a:string>93v2</a:string>
<a:string>A42</a:string>
<a:string>A42v1</a:string>
<a:string>A46</a:string>
<a:string>A48</a:string>
<a:string>A9</a:string>
<a:string>P6</a:string>
<a:string>V5</a:string>
</Routes>
<StopID>1000499</StopID>
</Stop>
<Stop>
<Lat>38.88136</Lat>
<Lon>-76.988525</Lon>
<Name>PENNSYLVANIA AVE SE + 13TH ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>30N</a:string>
<a:string>30S</a:string>
<a:string>32</a:string>
<a:string>32v1</a:string>
<a:string>34</a:string>
<a:string>36</a:string>
</Routes>
<StopID>1000587</StopID>
</Stop>
<Stop>
<Lat>38.880028</Lat>
<Lon>-76.985716</Lon>
<Name>POTOMAC AVE (S RDWY) + 14TH ST</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7v1</a:string>
<a:string>V7v2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1000565</StopID>
</Stop>
<Stop>
<Lat>38.880135</Lat>
<Lon>-76.985501</Lon>
<Name>PENNSYLVANIA AVE SE + POTOMAC AVE S</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>30N</a:string>
<a:string>30S</a:string>
<a:string>32</a:string>
<a:string>32v1</a:string>
<a:string>34</a:string>
<a:string>36</a:string>
<a:string>39</a:string>
<a:string>K11</a:string>
<a:string>M6</a:string>
</Routes>
<StopID>1003185</StopID>
</Stop>
<Stop>
<Lat>38.87935</Lat>
<Lon>-76.994258</Lon>
<Name>I ST + BET 8TH & 9TH STS</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7cv2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1000551</StopID>
</Stop>
<Stop>
<Lat>38.881628</Lat>
<Lon>-76.988173</Lon>
<Name>PENNSYLVANIA AVE SE + 13TH ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>30N</a:string>
<a:string>30S</a:string>
<a:string>32</a:string>
<a:string>34</a:string>
<a:string>36</a:string>
<a:string>A11</a:string>
</Routes>
<StopID>1000593</StopID>
</Stop>
<Stop>
<Lat>38.880519</Lat>
<Lon>-76.985482</Lon>
<Name>PENNSYLVANIA AVE SE + POTOMAC AVE S</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>30N</a:string>
<a:string>30S</a:string>
<a:string>32</a:string>
<a:string>34</a:string>
<a:string>36</a:string>
<a:string>39</a:string>
<a:string>A11</a:string>
</Routes>
<StopID>1000576</StopID>
</Stop>
<Stop>
<Lat>38.880648</Lat>
<Lon>-76.985378</Lon>
<Name>POTOMAC AVE + 14TH ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>J13</a:string>
<a:string>K11</a:string>
<a:string>M6</a:string>
</Routes>
<StopID>1000578</StopID>
</Stop>
<Stop>
<Lat>38.877849</Lat>
<Lon>-76.994875</Lon>
<Name>8TH ST SE + L ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>90</a:string>
<a:string>90v1</a:string>
<a:string>92</a:string>
<a:string>92c</a:string>
<a:string>93</a:string>
<a:string>93cv1</a:string>
</Routes>
<StopID>1000527</StopID>
</Stop>
<Stop>
<Lat>38.880216</Lat>
<Lon>-76.984727</Lon>
<Name>PENNSYLVANIA AVE SE + POTOMAC AVE S</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>B2</a:string>
<a:string>B2c</a:string>
<a:string>B2vS2</a:string>
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7cv2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1002965</StopID>
</Stop>
<Stop>
<Lat>38.877254</Lat>
<Lon>-76.995082</Lon>
<Name>8TH ST SE + L ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>90</a:string>
<a:string>92</a:string>
<a:string>93</a:string>
<a:string>93v2</a:string>
<a:string>V5</a:string>
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7cv2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1003755</StopID>
</Stop>
<Stop>
<Lat>38.876616</Lat>
<Lon>-76.994764</Lon>
<Name>M ST + 8TH ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>90</a:string>
<a:string>92</a:string>
<a:string>92c</a:string>
<a:string>93</a:string>
<a:string>93cv1</a:string>
<a:string>A42</a:string>
<a:string>A42v1</a:string>
<a:string>A46</a:string>
<a:string>A46v1</a:string>
<a:string>A48</a:string>
<a:string>A48v1</a:string>
<a:string>A9</a:string>
<a:string>P6</a:string>
</Routes>
<StopID>1000514</StopID>
</Stop>
<Stop>
<Lat>38.879444</Lat>
<Lon>-76.983804</Lon>
<Name>PENNSYLVANIA AVE SE + 15TH ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>30N</a:string>
<a:string>30S</a:string>
<a:string>32</a:string>
<a:string>32v1</a:string>
<a:string>34</a:string>
<a:string>36</a:string>
<a:string>K11</a:string>
<a:string>M6</a:string>
<a:string>V7</a:string>
<a:string>V7c</a:string>
<a:string>V7cv1</a:string>
<a:string>V7v1</a:string>
<a:string>V7v2</a:string>
<a:string>V8</a:string>
<a:string>V9</a:string>
</Routes>
<StopID>1000559</StopID>
</Stop>
<Stop>
<Lat>38.879911</Lat>
<Lon>-76.983766</Lon>
<Name>15TH ST SE + PENNSYLVANIA AVE SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>B2</a:string>
<a:string>B2v1</a:string>
<a:string>B2vS1</a:string>
<a:string>B2vS2</a:string>
</Routes>
<StopID>1000571</StopID>
</Stop>
<Stop>
<Lat>38.882743</Lat>
<Lon>-76.990934</Lon>
<Name>PENNSYLVANIA AVE SE + E ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>30N</a:string>
<a:string>30S</a:string>
<a:string>32</a:string>
<a:string>34</a:string>
<a:string>36</a:string>
<a:string>A11</a:string>
</Routes>
<StopID>1000611</StopID>
</Stop>
<Stop>
<Lat>38.881127</Lat>
<Lon>-76.994876</Lon>
<Name>8TH ST + G ST</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>90</a:string>
<a:string>90v1</a:string>
<a:string>92</a:string>
<a:string>93</a:string>
</Routes>
<StopID>1000585</StopID>
</Stop>
<Stop>
<Lat>38.882922</Lat>
<Lon>-76.99</Lon>
<Name>E STREET SE + 12TH ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>C40</a:string>
</Routes>
<StopID>1003600</StopID>
</Stop>
<Stop>
<Lat>38.88095</Lat>
<Lon>-76.983833</Lon>
<Name>POTOMAC AVE SE + 15TH ST SE</Name>
<Routes
xmlns:a="http://schemas.microsoft.com/2003/10/Serialization/Arrays">
<a:string>B2</a:string>
<a:string>B2c</a:string>
<a:string>B2vS2</a:string>
</Routes>
<StopID>1000582</StopID>
</Stop>
</Stops>
</StopsResp>
Code samples
@ECHO OFF
curl -v -X GET "https://api.wmata.com/Bus.svc/Stops?Lat={string}&Lon={string}&Radius={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["Lat"] = "{string}";
queryString["Lon"] = "{string}";
queryString["Radius"] = "{string}";
var uri = "https://api.wmata.com/Bus.svc/Stops?" + 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/Stops");
builder.setParameter("Lat", "{string}");
builder.setParameter("Lon", "{string}");
builder.setParameter("Radius", "{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
"Lat": "{string}",
"Lon": "{string}",
"Radius": "{string}",
};
$.ajax({
url: "https://api.wmata.com/Bus.svc/Stops?" + $.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/Stops";
NSArray* array = @[
// Request parameters
@"entities=true",
@"Lat={string}",
@"Lon={string}",
@"Radius={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/Bus.svc/Stops');
$url = $request->getUrl();
$headers = array(
// Request headers
'api_key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
'Lat' => '{string}',
'Lon' => '{string}',
'Radius' => '{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
'Lat': '{string}',
'Lon': '{string}',
'Radius': '{string}',
})
try:
conn = httplib.HTTPSConnection('api.wmata.com')
conn.request("GET", "/Bus.svc/Stops?%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': '{string}',
'Lon': '{string}',
'Radius': '{string}',
})
try:
conn = http.client.HTTPSConnection('api.wmata.com')
conn.request("GET", "/Bus.svc/Stops?%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/Stops')
query = URI.encode_www_form({
# Request parameters
'Lat' => '{string}',
'Lon' => '{string}',
'Radius' => '{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