REST API: Trails

The main endpoint for trails. Get returns a single trail. The Set uses GET for search and POST for inserts. The GETs require an API key, the POST requires OAuth. Inserted trails are reviewed by TrailLink staff.

Note that the Set GET only returns a subset of the fields used in the individual GET. The Resource Properties listed below has all definitions. See the individual sample for the specific fields used for each operation.

Resource URI

/Trails/6683560?api_key=xxxx

Resource Properties

Parameter Format Description Allows Null
acctStatus string N Partially Open O Open P Pre R Project W Waiting for Approval On POST status will be set to W No
activities string Comma-separated list of activities: See activities for valid values. no
category string see Categories for values No
counties string Comma-separated list of counties. no 
description string Description of the trail no
distanceFromSearch decimal Distance in miles. between the trail and the geographic search argument. If the search did not contain a geographic argument, then this value will be -1. The distance returned is the distance between the two closest points. no
detailurl string A portion of the traillink.com url no
endPt1 string Textual description of trail start. No
endPt2 string Textual description of trail end. No
guidebookImage string Image name for guidebook. no 
guidebookLink string Link to guidebook in RTC store. no 
hasImages bool If true then we have images for the trail no 
hasReviews bool If true then we have reviews for the trail. no 
hasSpatial bool If true then we have spatial data for the trail no 
imageThumb long imageID for a trail images no
isRailtrail bool True if the trail is a rail-trail no
isTopTrail bool True if the trail is an RTC-designated top trail no
lat decimal Latitude for a point on the trail in decimal degrees no 
length decimal Length of trail in miles no
lon decimal Longitude for a point on the trail in decimal degrees no
parking string Description of parking no 
ratingAverage decimal Average user rating. no 
ratingCount int Number of user ratings no 
reviewCount int Number of user reviews no 
states string Comma-separated list of states. no
surfaces string Comma-separated list of surfaces: See surfaces for valid values no 
tokenCost int Cost in tokens to purchase the trail. No,
except for POST/add
trailID long Unique ID for Trail No,
except for POST/add
trailName string Name of the trail No

Error Responses

Trail ID is required.

Invalid Lat/Lon

Invalid Zipcoode

Invalid State

Invalid City

Invalid City and State combination

HTTP GET

Gets all data associated with this trail.

JSON Request:

Request Body is empty

JSON Response:

{
"acctStatus": "O",
"activities": "ATV",
"category": "Greenway/Non-RT",
"counties": "Autauga",
"description": " test test \n",
"detailurl": "trail-name-test-2",
"endPt1": "test1",
"endPt2": "test2",
"guidebookImage": "se_guide.jpg",
"guidebookLink": "https://secure2.convio.net/rtt/site/Ecommerce?\nVIEW_PRODUCT=true&product_id=1741&store_id=1141&autologin=true",
"hasImages": true,
"hasReviews": true,
"hasSpatial": false,
"imagethumb": 26620,
"isRailtrail": false,
"isTopTrail": false,
"lat": 32.5394314704421,
"length": 1,
"lon": -86.6413013815232,
"parking": " test test \n",
"ratingAverage": 5,
"ratingCount": 1,
"reviewCount": 2,
"states": "Alabama",
"surfaces": "Asphalt",
"tokenCost": 2,
"trailID": 6683560,
"trailName": "Trail Name Test 2"
}

XML Request:

Request Body is empty

XML Response:


REST API: Trails Set

Operations on the set of trails.  The Set GET is the trail search method.  The POST is the new trail insert.

Resource URI

/Trails/?keyword=trail%20name%20test&api_key=

Set Filters

ParameterFormatDescriptionAllows Null
keyword  string Words to match against the trail descriptions.  yes
state  string  State trail is in.  yes 
city  string  City trail is in.  yes 
activities  string  List of activities, separated by commas  yes 
surfaces  string List of surfaces, separated by commas  yes
length  number Min|max length trail can be (e.g., 1|999 means more than 1mi, less than 999 miles).  yes 
zipcode  number Use in location search.  yes 
lat  number Use in location search.  yes 
lon  number Use in location search.  yes 
distance  number Distance out from zipcode for which to search.  yes 
showProject  string  Y, to include project trails too.  yes 
list_codes  string  For example TOP100 for the 100 top rated trails.  yes 
detail_url  string  The trail url to search for.  yes 
cat  string ANY or R,C or G  yes
inc_desc  number Include Description Y or N  yes
offset  number The next trail in the result set to return.  yes 
limit  number The maximum number of trails to return.  yes 
sort   string List of fields to sort by. Leave blank to use default sort.  yes 

HTTP GET

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:

HTTP POST

Adds a new trail to the system. The trail will be assigned a status of W and will be reviewed by RTC staff. Requires OAuth. Returns the new trail's trailID

Note that this is not the same object as the ones used for GET.

JSON Request:

{
"trailName":"Test new trail",
"length":"10.2",
"category":"R",
"endPt1":"Fairfax",
"endPt2":"Bethesda",
"website1":"http://www.traillink.com",
"website2":"http://www.railstotrails.org",
"website3":"",
"surfaces": "ASPH,DIRT",
"activities": "ATV,BIKE,FISH",
"states": "VA, MD, DC",
"counties" : "Montgomery,Arlington,Fairfax,Prince Georges,Washington",
"parking" : "There is plenty of parking",
"description":"A fairly long description to test",
"submitter":"johnqsample"
}

JSON Response:

7482843

XML Request:

XML Response: