By: Matthew Malone
- Schema
- End Points
- GET Endpoints
- POST Endpoints
- DELETE Endpoints
- API's used
- Project Management Board
Many to Many
Many beaches have many whale sigthings.
Many Whales have been sighted at many different beaches.
Beach Info Object Example
{
"ID": 36,
"COUNTY": "Del Norte",
"NameMobileWeb": "Crescent Beach Picnic Area",
"LocationMobileWeb": "Enderts Beach Rd., .5 mi. S. of Hwy. 101",
"DescriptionMobileWeb": "A scenic overlook is at S. end of Enderts Beach Rd.",
"PHONE_NMBR": "",
"FEE": "No",
"PARKING": "Yes",
"DSABLDACSS": "Yes",
"RESTROOMS": "Yes",
"VISTOR_CTR": "No",
"DOG_FRIENDLY": "Yes",
"EZ4STROLLERS": "Yes",
"PCNC_AREA": "Yes",
"CAMPGROUND": "No",
"STRS_BEACH": "No",
"PTH_BEACH": "Yes",
"VOLLEYBALL": "",
"FISHING": "Yes",
"BOATING": "No",
"GEOGR_AREA": "E. Crescent Beach to Lagoon Creek",
"Photo_1": "",
"Photo_2": "",
"Photo_3": "",
"Photo_4": "",
"BIKE_PATH": "No"
}
Whale Sighting Info Object Example
{
"species": "harbor porpoise",
"quantity": "20",
"sighted_at": "2017-10-01T00:38:00Z",
"orca_type": "unknown",
"beachId": 36,
"beachName": "Crescent Beach Picnic Area"
}
GET
endpoints
GET path:/api/v1/beaches
- Sample Response (ok) status: 200
- Will return an array of all beaches, each as an object.
- Each beach object will contain the following:
[{
"ID": 1,
"COUNTY": "Del Norte",
"NameMobileWeb": "Pelican State Beach",
"LocationMobileWeb": "W. of Hwy. 101, .5 mi. S. of Oregon border",
"DescriptionMobileWeb": "Wide beach with driftwood, day use only",
"PHONE_NMBR": "",
"FEE": "No",
"PARKING": "Yes",
"DSABLDACSS": "No",
"RESTROOMS": "No",
"VISTOR_CTR": "No",
"DOG_FRIENDLY": "",
"EZ4STROLLERS": "",
"PCNC_AREA": "",
"CAMPGROUND": "No",
"STRS_BEACH": "No",
"PTH_BEACH": "Yes",
"VOLLEYBALL": "",
"FISHING": "Yes",
"BOATING": "No",
"GEOGR_AREA": "A. Northern Del Norte",
"Photo_1": "https://www.coastal.ca.gov/access-photos/02_del_norte/02_northern_del_norte/Pelican_State_Beach_2013_07_01_4908.jpg",
"Photo_2": "https://www.coastal.ca.gov/access-photos/02_del_norte/02_northern_del_norte/Pelican_State_Beach_SFS_2013_07_01_4903.jpg",
"Photo_3": "",
"Photo_4": "",
"BIKE_PATH": "No"
}]
Sample Response (error) status: 404
{ error: "Cannot retrieve Beach Data (try again just for the halibut)" }
GET path:/api/v1/whale_sightings
- Sample Response (ok) status: 200
- Will return an array of all sightings from all beaches
- Each sighting object will contain the following:
[{
"species": "orca",
"quantity": null,
"sighted_at": "2016-10-07T23:56:00Z",
"orca_type": "southern resident",
"beachId": 1,
"beachName": "Pelican State Beach"
}]
- Sample Response (error) status: 404
{
error: "Cannot retreive Whale Sightings Data (this blows)"
}
GET path: /api/v1/beaches/:id
- Sample Response (ok) status: 200
- Will return an the single requested beach as an object.
- Each beach object will contain the following:
{
"ID": 1,
"COUNTY": "Del Norte",
"NameMobileWeb": "Pelican State Beach",
"LocationMobileWeb": "W. of Hwy. 101, .5 mi. S. of Oregon border",
"DescriptionMobileWeb": "Wide beach with driftwood, day use only",
"PHONE_NMBR": "",
"FEE": "No",
"PARKING": "Yes",
"DSABLDACSS": "No",
"RESTROOMS": "No",
"VISTOR_CTR": "No",
"DOG_FRIENDLY": "",
"EZ4STROLLERS": "",
"PCNC_AREA": "",
"CAMPGROUND": "No",
"STRS_BEACH": "No",
"PTH_BEACH": "Yes",
"VOLLEYBALL": "",
"FISHING": "Yes",
"BOATING": "No",
"GEOGR_AREA": "A. Northern Del Norte",
"Photo_1": "https://www.coastal.ca.gov/access-photos/02_del_norte/02_northern_del_norte/Pelican_State_Beach_2013_07_01_4908.jpg",
"Photo_2": "https://www.coastal.ca.gov/access-photos/02_del_norte/02_northern_del_norte/Pelican_State_Beach_SFS_2013_07_01_4903.jpg",
"Photo_3": "",
"Photo_4": "",
"BIKE_PATH": "No"
}
- Sample Response (error) status: 404
{
error: `Could not get beach with id 22, Can you please be more Pacific?`
}
Path: /api/v1/beaches/:id/whale_sightings
- Sample Response (ok) status: 200
- Will return an array of 100 whale sight objects
- Example partial array that will be returned:
[
{
"species": "orca",
"quantity": "5",
"sighted_at": "2017-11-09T18:11:00Z",
"orca_type": "unknown",
"beachId": 53,
"beachName": "Coastal Trail (Humboldt)"
},
{
"species": "harbor porpoise",
"quantity": "20",
"sighted_at": "2017-10-01T00:38:00Z",
"orca_type": "unknown",
"beachId": 53,
"beachName": "Coastal Trail (Humboldt)"
},
{
"species": "humpback",
"quantity": "1",
"sighted_at": "2017-09-03T00:45:00Z",
"orca_type": "unknown",
"beachId": 53,
"beachName": "Coastal Trail (Humboldt)"
}
]
- Sample Response (error) status: 404
- Note, this is probably due to no beach with the beach id requested
{
error: `Could not get whale sightings with beach id 22, it might be because sea weed.`
}
GET path: '/api/v1/beaches/sighting_type/:id'
- the id is the specific whale/marine animal
- Response (ok) status: 200 - will return an array of all beaches where there was a whale/marine animal sighting of the requested type.
POST
endpoints
POST path:/api/v1/whale_sightings
This Post requires species(whale/marine animal), sighted_at(day and time), beachdID(id of beach), beachName(name of beach).
Format of POST body:
{
species: <String>,
quantity: <Number>, //optional
sighted_at: <String>,
orca_type: <String>, //optional
beachId: <Num>,
beachName: <String>
}
- Sample Response (ok) status: 201
{ id: 98003}
- Sample Response (error) status: 422 - When all the parameters are not provided:
{
error: Expected format: {
species: <String>,
quantity: <Number>(optional),
sighted_at: <String>,
orca_type: <String>(optional),
beachId: 1,
beachName: <String>
}.
You're missing a [requiredParameter] property.
}
- Sample Response (error) status: 404
{ error: "Cannot add whale/marine animal sighting to database, are you sure we have a planktonic relationship?" }
POST path: /api/v1/beaches
This Post requires NameMobileWeb(beach name), LocationMobileWeb(beach address), DescriptionMobileWeb(brief description of beach, ex. rocky, sandy, cove, etc.), PARKING(yes or no).
Format of POST body:
{
"COUNTY": <String>,
"NameMobileWeb": <String>,
"LocationMobileWeb": <String>,
"DescriptionMobileWeb": <String>,
"PHONE_NMBR": <String>,
"FEE": <String>,
"PARKING": <String>,
}
- Sample Response (ok) status: 201
{ id: 916}
- Sample Response (error) status: 422 - When all the parameters are not provided:
{ error: Expected format: {
"COUNTY": <String>,
"NameMobileWeb": <String>,
"LocationMobileWeb": <String>,
"DescriptionMobileWeb": <String>,
"PHONE_NMBR": <String>,
"FEE": <String>,
"PARKING": <String>,
}. You're missing a [requiredParameter] property. }
- Sample Response (error) status: 404
{
error: "Cannot add beach to the database, looks like it's time to Netflix and krill."
}
DELETE
endpoints
DELETE path:/api/v1/whale_sightings/:id
- this only requires the id of the whale/marine animal sighting you want to delete
- Sample Response (ok) status: 201 - the id of the deleted item will be returned in an object
{ id: 916}
- Sample Response (error) status: 422
{
error: "Cannot delete whale/marine animal sighting from database, I'd call the Codfather"
}