-
Notifications
You must be signed in to change notification settings - Fork 4
Our API
We have four models: states, parks, campgrounds and events. These models connect to one another, for example, states have a number of campgrounds and those campgrounds belong to the same state.
Our RESTful API allows users to request data models from our database by specifying attributes. For example if you wanted to get a specific park in Texas (say Big Bend), then you would submit a get request with the parks park_id (Big Bend's park_id = 2). A sample request would be as follows:
http://sweetoutdoors.me/parks/2
Note: The number appended at the end of the URL is the park_id for the Park the user is requesting information on.
Once a get request has been made, a response will be returned to the user in a JSON format in the form of a dictionary object. This dictionary will store the requested information of our park. An example JSON response is as follows:
[ { "idnum": "2", "name": "Big Bend National Park", "latitude": "29.1275", "longitude": "103.2425", "address": "PO Box 129 Big Bend National Park", "phone": "(432) 477-2251", "rating": "4.7", "website": "https://www.nps.gov/bibe/index.htm", "zipcode": "79834", "photo_url": "https://farm3.staticflickr.com/2814/11052915046_4be39145f4_b.jpg", "zipregion": "798", "state_id_fk": "0" } ]
The results of the queries will be stored in JSON format as dictionaries, with attribute names serving as keys.
###All Parks
Users may also request a list of all parks, states, campgrounds, or events. An sample request is as follows:
http://sweetoutdoors.me/parks
An example JSON response for this request is as follows:
[ { "id": "0", "name": "McKinney Falls State Park" }, { "id": "1", "name": "Death Valley National Park" }, { "id": "2", "name": "Big Bend National Park" } ]
Requesting information from our other models is similar to how a user requests information about parks. To find more details about our API, please visit our Apiary page