Notes:
- all URL parameters are lowercase with - replacing all spaces.
- state parameters are the requested state's 2 letter indentifier
Open endpoints require no Authentication. Used to fetch campground data.
Fetch all campgrounds.
Endpoint:
Method: GET
Type: application/json
URL:/campgroundsSuccess Response:
Code: 200 OK
{
"sucess": true,
"count": 2,
"data": [
{
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
},
{
"location": {
"coordinates": [
36.457097,
-116.866158
],
"formattedAddress": "328 Greenland Blvd, Death Valley, CA 92328-9600, US"
},
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
},
]
}Fetch all campgrounds within a radius from the any zipcode.
Endpoint:
Method: GET
Type: application/json
URL: /campgrounds/:zipcode/:radiusRadius is assumed to be miles Success Response:
Code: 200 OK
{
"sucess": true,
"count": 1,
"data": [
{
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
},
]
}Fetch all campgrounds within a specific state.
Endpoint:
Method: GET
Type: application/json
URL: /:stateSuccess Response:
Code: 200 OK
{
"sucess": true,
"count": 1,
"data": [
{
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
},
]
}Fetch all campgrounds within a specific park.
Endpoint:
Method: GET
Type: application/json
URL: /:state/:parkSuccess Response:
Code: 200 OK
{
"sucess": true,
"count": 1,
"data": [
{
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
},
]
}Fetch a specific campground.
Endpoint:
Method: GET
Type: application/json
URL: /:state/:park/:campgroundSuccess Response:
Code: 200 OK
{
"sucess": true,
"count": 1,
"data": [
{
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
},
]
}Successful login provides the user with a token for use with protected routes. All fields are required.
Endpoint:
Method: POST
Type: application/json
URL: /auth/loginBody Constraints:
{
"name": "[valid name of registered user]",
"password": "[valid password]"
}Success Response:
Code: 200 OK
{
"token": "[valid token to be used with requests]"
}Error Response:
Condition: Name and/or password are invalid.
Code: 401 Unauthorized
{
"success": false,
"error": "Invalid credentials"
}Require a valid token to be included in the header of the request. A token can be acquired from via Login.
Allows registered users to add a campground. All fields are required except 'vote'. Should a user want to vote, use 1 or -1 to indicate positive or negative review.
Endpoint:
Method: POST
Type: application/json
URL: /:stateThe state attribute of the body should match that of the endpoint's URL
Body Constraints:
{
"name": "[name of campground]" [required],
"park": "[name of park]" [required],
"state": "[state's 2 letter identifier]" [required],
"address": "[street address, city, state, zip code]" [required for new parks],
"fee": [integer value] [required],
"toilet": [boolean] [required],
"water": [boolean] [required],
"yearRound": [boolean] [required],
"vote": [1 or -1] [optional]
}Success Response:
Code: 201 Created
{
"success": true,
"resData": {
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
}
}Error Response:
Condition: Campground data already exists.
Code: 400 Bad Request
{
"success": false,
"error": "Campground associated with the provided park already exists."
}Condition: The park associated with the campground was not found and an address is required to proceed with submitting both a new campground and a new park.
Code: 404 Not Found
Content Example:
{
"success": false,
"error": "Please include an address for either the campground or the park"
}Allows registered contributors to edit an existing campground.
Endpoint:
Method: PUT
Type: application/json
URL: /:state/:park/:campgroundBody Constraints:
{
"address": "[street address, city, state, zip code]" [optional],
"fee": [integer value] [optional],
"toilet": [boolean] [optional],
"water": [boolean] [optional],
"yearRound": [boolean] [optional],
}Updating the address will only apply to the requested campground and not the associated park
Success Response:
Code: 200 OK
{
"success": true,
"resData": {
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
}
}Error Response:
Condition: Attempted to edit prohibited fields. Such attempts result in not being able to find a correlating campground to edit.
Code: 404 Not Found
{
"success": false,
"error": "park,state,vote are prohibited fields for updates"
}Condition: Invalid token in request
Code: 401 Unauthorized
{
"success": false,
"error": "Not authorized to access this route"
}Provide a positive review of a campground.
Endpoint:
Method: PUT
Type: application/json
URL: /:state/:park/:campground/goodSuccess Response:
Code: 200 OK
{
{
"success": true,
"resData": {
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
}
}
}Error Response:
Condition: Invalid token in request
Code: 401 Unauthorized
{
"success": false,
"error": "Not authorized to access this route"
}Provide a negative review of a campground.
Endpoint:
Method: PUT
Type: application/json
URL: /:state/:park/:campground/badSuccess Response:
Code: 200 OK
{
{
"success": true,
"resData": {
"name": "name of campground",
"park": "name of park",
"state": "state's 2 letter identifier",
"location": {
"coordinates": [
[lat value],
[lon value]
],
"formattedAddress": "[submitted address in formatted form]"
},
"fee": [integer value],
"toilet": [boolean],
"water": [boolean],
"yearRound": [boolean],
"lastModifiedBy": "[user's name]",
"photo": "photo-camp-no-photo.jpg",
"lastUpdate": "[date of creation]",
"slug": "ccc-quarry-backpacking-campsite-2",
"votes": {
"total": [# of total votes],
"percentPos": [% of votes that are positive]
},
"parkSlug": "[slug of park associated with campground]"
}
}
}Error Response:
Condition: Invalid token in request
Code: 401 Unauthorized
{
"success": false,
"error": "Not authorized to access this route"
}Removes active cookie associated with the user's account.
Endpoint:
Method: GET
Type: application/json
URL: /auth/logoutSuccess Response:
Code: 200 OK
Error Response:
Condition: Invalid token in request
Code: 401 Unauthorized
{
"success": false,
"error": "Not authorized to access this route"
}