Skip to content

API to support collecting data on first come first serve campgrounds

License

Notifications You must be signed in to change notification settings

chamoo334/fcfs-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

First Come First Served

Notes:
- all URL parameters are lowercase with - replacing all spaces.
- state parameters are the requested state's 2 letter indentifier

Open Endpoints

Open endpoints require no Authentication. Used to fetch campground data.

1. Get All Campgrounds

Fetch all campgrounds.

Endpoint:

Method: GET
Type: application/json
URL:/campgrounds

Success 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]"
        },
    ]
}

2. Get Campgrounds Within a Radius

Fetch all campgrounds within a radius from the any zipcode.

Endpoint:

Method: GET
Type: application/json
URL: /campgrounds/:zipcode/:radius

Radius 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]"
        },
    ]
}

3. Get Campgrounds By State

Fetch all campgrounds within a specific state.

Endpoint:

Method: GET
Type: application/json
URL: /:state

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]"
        },
    ]
}

4. Get Campgrounds By Park

Fetch all campgrounds within a specific park.

Endpoint:

Method: GET
Type: application/json
URL: /:state/:park

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]"
        },
    ]
}

5. Get A Single Campground

Fetch a specific campground.

Endpoint:

Method: GET
Type: application/json
URL: /:state/:park/:campground

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]"
        },
    ]
}

6. Login

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/login

Body 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"
}

Closed Endpoints

Require a valid token to be included in the header of the request. A token can be acquired from via Login.

1. Add Campground

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: /:state

The 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"
}

2. Edit Campground

Allows registered contributors to edit an existing campground.

Endpoint:

Method: PUT
Type: application/json
URL: /:state/:park/:campground

Body 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"
}

3. Up Vote Campground

Provide a positive review of a campground.

Endpoint:

Method: PUT
Type: application/json
URL: /:state/:park/:campground/good

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: Invalid token in request

Code: 401 Unauthorized

{
    "success": false,
    "error": "Not authorized to access this route"
}

4. Down Vote Campground

Provide a negative review of a campground.

Endpoint:

Method: PUT
Type: application/json
URL: /:state/:park/:campground/bad

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: Invalid token in request

Code: 401 Unauthorized

{
    "success": false,
    "error": "Not authorized to access this route"
}

5. Logout User

Removes active cookie associated with the user's account.

Endpoint:

Method: GET
Type: application/json
URL: /auth/logout

Success Response:

Code: 200 OK

Error Response:

Condition: Invalid token in request

Code: 401 Unauthorized

{
    "success": false,
    "error": "Not authorized to access this route"
}

Community Website

Purpose:

FCFS was created to facilitate the collection and organization of campgrounds that do not accept reservations. In addition to promoting community driven data collection, the API ws created to assist with making the data easily available for use within any other application.

Community website can be found here.

Development:

Back to top

About

API to support collecting data on first come first serve campgrounds

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published