This is the main search method for trails. Searches break down as follows:
These are the basic search criteria
{keyword} - All trails with trail name or description conatining thethe terms "trail", "name", and "test"
/Trails/?keyword=trail%20name%20test&api_key=xxx
{state} - trail is in {state}. To get all trails within the District of Columbia, do:
/Trails/?state=DC&api_key=xxx
{city} (Requires {distance}: Trail is within {distance} miles of {city}. If state was also passed, we use it with the city. This gets trails within 30 miles of Washington, PA
/V1/Trails/?city=washington&state=PA&distance=30
If state was not passed, we choose the largest city by population. So this gets trails within 30 miles of washington dc:
/Trails/?city=washington&distance=30&api_key=xxx
{zipcode} (Requires {distance}) - trail is within {distance} miles of zipcode {zipcode}. To get all trails within 30 miles of zipcode 20001 use
/Trails/?zipcode=20001&distance=30&api_key=xxx
{lat}{lon} (Requires {distance}) - trail is within {distance} miles of lat/lon {lat}{lon}. To get all trails within 30 miles of 39.0025414940, -77.04624213 use
/Trails/?lat=39.0025414940&lon=-77.04624213&distance=30&api_key=xxx
{distance} - only used in conjunction with city, zip, and lat/lon.
These filter the result set
&activities=HIKE,WHEEL - trail has Hiking OR Wheelchair activities. We default to ANY.
&surfaces=ASPH,SAND - trail has Asphalt or Sand surface. We default to ANY.
&length=5|10 - trail length is between 5 and 10 miles. We default to 0 and 99999.
So to get all bicyling asphalt trails between 10 and 20 miles long within 30 miles of Washington, DC, do
/Trails/?activities=BIKE&surfaces=ASPH&length=10|20&state=DC&city=Washington&distance=30&api_key=xxx
The ones below will not be useful to most consumers:
&showProject=Y - if Y, result set will include project trails, else it won't. We default to Y
&list_codes=TOP100 - trail has the list code TOP100. RTC can add or remove list codes from trails
&detail_url=capital-crescent-trail - our url formatted string. will only ever return 1 trail
&cat=R,C - trail has one of the comma-separated categories. We default to ANY
&inc_desc=N -If you don't want the description, Y if you do. Descriptions can be long and can make searches slow
Error Checking
The following will trigger a 400 response with an error message in the body:
Invalid Lat/Lon
Invalid Zipcoode
Invalid State
Invalid City
Invalid City and State combination
Paging/Sorting controls
&offset=0&limit=100 - return the first 100 rows only
&sort={sort} - sort by the field name
JSON Request:
Request Body is empty
JSON Response:
[{
"acctStatus": "O",
"activities": "ATV",
"counties": "Autauga",
"description": " test test \u000a",
"detailurl": "trail-name-test-2",
"distanceFromSearch": -1,
"hasSpatial": false,
"imagethumb": 26620,
"isRailtrail": false,
"isTopTrail": false,
"lat": "32.53943147044210",
"length": 1,
"lon": "-86.64130138152320",
"ratingAverage": 5,
"reviewCount": 2,
"states": "AL",
"surfaces": "Asphalt",
"trailID": 6683560,
"trailName": "Trail Name Test 2"
}]
XML Request:
Request Body is empty
XML Response: