Skip to content

3. APIs

Ryan Heidema edited this page Apr 13, 2021 · 24 revisions

Get Venues

Returns a complete list of all venues sorted alphabetically, or by proximity to the user's current latitude and longitude.

link to source code

Endpoint: GET /venues/

Request Parameters

Key Location Type Description
lat URL Parameter Float User's latitude (optional)
lon URL Parameter Float User's longitude (optional)

Response Codes

Code Description
200 OK Success
400 Bad Request Invalid Parameters

Returns

If no URL parameters, list will sorted alphabetically, otherwise sorted by user's proximity.

Key Location Type Description
data JSON List of all venues Data associated with each venue
url JSON String Self-identifying URL

Example

curl -X GET https://api.OUR_SERVER/venues/?lat=42.29&lon=-83.72

{
    "data": [
        {
    	    "name": "Michigan's Adventure",
    	    "description": "...",
    	    "image_url": "/media/fjdkfjda.jpg",
            "lat": 43.34,
            "lon": -86.28,
            "distance": 1.3
        },
        {
	    "name": "Disney World",
	    "description": "...",
	    "image_url": "/media/fjdafdak.jpg",
            "lat": 28.38,
            "lon": -81.56,
            "distance": 2.1
        },
        ...
    ],
    "url": "/api/venues/"
}

Get Destinations by Venue

Returns a complete list of all destinations for a specified venue sorted alphabetically, or by proximity to the user's current latitude and longitude.

link to source code

Endpoint: GET /venues/:id/destinations

Request Parameters

Key Location Type Description
lat URL Parameter Float User's latitude (optional)
lon URL Parameter Float User's longitude (optional)

Response Codes

Code Description
200 OK Success
400 Bad Request Invalid Parameters
404 Not Found Invalid Specified Venue ID

Returns

If no URL parameters, list will sorted alphabetically, otherwise sorted by user's proximity.

Key Location Type Description
data JSON List of all destinations Data associated with each venue
url JSON String Self-identifying URL

Example

curl -X GET https://api.OUR_SERVER/api/venues/152/destinations?lat=42.29&lon=-83.72

{
    "data": [
        {
    	    "name": "Mine Ride",
    	    "description": "...",
    	    "image_url": "/media/fjdkfjda.jpg",
            "lat": 43.34,
            "lon": -86.28,
            "distance": 0.5
        },
        {
	    "name": "Blue Streak",
	    "description": "...",
	    "image_url": "/media/fjdafdak.jpg",
            "lat": 28.38,
            "lon": -81.56,
            "distance": 0.9
        },
        ...
    ],
    "url": "/api/venues/152/destinations"
}

Get Directions to Destination

Returns a list of coordinates from a users location, to a specified destination.

link to source code

Endpoint: GET /venues/:id/destinations/:id/directions

Request Parameters

Key Location Type Description
lat URL Parameter Float User's latitude
lon URL Parameter Float User's longitude

Response Codes

Code Description
200 OK Success
400 Bad Request Invalid Parameters
404 Not Found Invalid Specified Venue / Destination ID

Returns

Key Location Type Description
data JSON List of coordinates Waypoints directions to destination
url JSON String Self-identifying URL
time_estimate JSON String Estimated time to walk to destination (in minutes)
distance JSON String Distance from users current location to destination (in miles)

Example

curl -X GET https://api.OUR_SERVER/api/venues/152/destinations/72/directions?lat=42.29&lon=-83.72

{
    "data": [
        {
            "lat": 43.34,
            "lon": -86.28
        },
        {
            "lat": 28.38,
            "lon": -81.56
        },
        {
            "lat": 28.38,
            "lon": -82.56
        },
        ...
    ],
    "url": "/api/venues/152/destinations",
    "time_estimate": 23,
    "distance": 2.6
}
Clone this wiki locally