Overview

    API Endpoint

          https://working-with-rest-apis.com
                

The Working with REST APIs API provides a way to learn how REST APIs work. The API allows for the creation, updating and deletion of simple messages. Please be a good citizen when using this API.

Get All Messages


# Here is a curl example
curl --location --request 
GET 'https://working-with-rest-apis.com/messages'
                

To get all messages you need to make a GET call to the following url :
https://working-with-rest-apis.com/messages



Result example :

{
    "chat": [
        {
            "id": 1,
            "message": "Down-sized scalable model"
        },
        {
            "id": 2,
            "message": "Visionary well-modulated leverage"
        },
        {
            "id": 3,
            "message": "Object-based encompassing matrix"
        }
    ]
}
                

Get Message


curl --location -g --request 
GET 'https://working-with-rest-apis.com/message/{id}'
                

To get a single message you need to make a GET call to the following url, repacing {id} with the record ID :
https://working-with-rest-apis.com/message/{id}



Result example :

{
    "chat": [
        {
            "id": 1,
            "message": "Down-sized scalable model"
        }
    ]
}
                

Post Message


curl --location --request 
POST 'https://working-with-rest-apis.com/message' \
--header 'API_KEY: readthisbook' \
--header 'Content-Type: application/json' \
--data-raw '{"message": "The message text goes here"}'
                

To post a message you need to make a POST call to the following url
https://working-with-rest-apis.com/message

BODY

JSON: {"message": "The message text goes here"}



Result example :

{
    "success": true,
    "response": "The record was written to the database",
    "message": "The message text goes here",
    "recordID": "48"
}
                

HEADERS

Field Type Description Value
API_KEY String Authorization needed for POST, PUT and DELETE methods readthisbook

Put Message


curl --location --request 
PUT 'https://working-with-rest-apis.com/message' \
--header 'API_KEY: readthisbook' \
--header 'Content-Type: application/json' \
--data-raw '{"id":1,"message": "The message text goes here"}'
                

To update a message you need to make a PUT call to the following url
https://working-with-rest-apis.replit.app/message Use the record ID in the body to determine with record to update, along with the updated message

BODY

JSON: {"id":1,message":"The message text goes here"}



Result example :

{
    "success": true,
    "response": "The record was written to the database",
    "message": "The message text goes here",
    "recordID": "48"
}
                

HEADERS

Field Type Description Value
API_KEY String Authorization needed for POST, PUT and DELETE methods readthisbook

Delete Message


curl --location --request DELETE 'https://working-with-rest-apis.replit.app/message' \
--header 'API_KEY: readthisbook' \
--header 'Content-Type: application/json' \
--data-raw '{"id":48}'
                

To delete a message you need to make a DELETE call to the following url using the id of the message in the body
https://working-with-rest-apis.com/message

BODY

JSON: {"id": "48"}



Result example :

{
    "success": true
}
                

HEADERS

Field Type Description Value
API_KEY String Authorization needed for POST, PUT and DELETE methods readthisbook

Errors

The API uses the following error codes:

Error Code Meaning
401 Unauthorized. Ensure for ant POST, PUT or DELETE requests you have added the API_KEY to the Headers
404 Not Found. Please check you have the right URI endpoint and formation