During this Code Along, we’ll be using Insomnia to make API requests to a REST-based API
https://css-colors-api.herokuapp.com/api/v1
Endpoint | Description |
---|---|
GET /colors |
retrieve list of colors |
GET /colors/:id |
retrieve details for one color |
POST /colors |
create a new color |
PUT /colors/:id |
update an existing color |
DELETE /colors/:id |
delete an existing color |
GET /colors/search?q=purple |
search for a color name or hexcode |
GET /colors/user_generated |
retrieve list of colors created by users |
GET /colors
)(GET) https://css-colors-api.herokuapp.com/api/v1/colors
Retrieve details for one color (GET /colors/:id
)
(GET) https://css-colors-api.herokuapp.com/api/v1/colors/3
Create a new color (POST /colors
)
Here we need to give the server additional information, the name and hexcode of the color we want to create
We are sending this additional information through a “body” of the request
(POST) https://css-colors-api.herokuapp.com/api/v1/colors
request body:
{
"color": {
"name": "Kareem Gray",
"hexcode": "#728ca0"
}
}
Update an existing color (PUT /colors/:id
)
Here we need to tell the server which color we want to update and the information we want to update
The update info is sent via a the “request body”
Here’s an example of updating the “name” of the color with the id = 7 to “Sky Blue”
(PUT) https://css-colors-api.herokuapp.com/api/v1/colors/7
request body:
{
"color": {
"name": "Sky Blue",
}
}
Delete a color (DELETE /colors/:id
)
(DELETE) https://css-colors-api.herokuapp.com/api/v1/colors/28
Search for color by name or hexcode (GET /colors/search?q={searchTerm}
)
(GET) https://css-colors-api.herokuapp.com/api/v1/colors/search?q=blue
Get all colors created by users (GET /colors/user_generated
)
(GET) https://css-colors-api.herokuapp.com/api/v1/colors/user_generated