Skip to content
larsverp edited this page May 22, 2020 · 1 revision

The hosts endpoint is used to list and create hosts.

📖 Get hosts (get method)

The get endpoints do not use any body text.

  • /api/hosts returns all hosts . - Authenticated users only!
  • /api/hosts/[id] returns hosts with specific id.
❌ Errors:
  • [] - There are no hosts to show
  • 404 - The specific hosts you're looking for doesn't exist.
✔️ On succes:

200 OK - returns a JSON object with all/specific host(s).


✏️ Create hosts (post method)

The post endpoints require all body data as described.

  • /api/hosts returns the data added to the DB.
    • first_name (required, string, max:191) - The first name
    • last_name (required, text) - The last name.
    • description (required, string) - The host description.
    • picture (required, active_url) - The host picture.
❌ Errors:
  • Error is only trown when body data is incorrect. Errors are in english like the example below.
{
    "message": "The given data was invalid.",
    "errors": {
        "picture": [
            "The picture is not a valid URL."
        ],
    }
}
✔️ On succes:

201 Created - returns a JSON object with the created host data.


📝 Update hosts (put method)

The put endpoints do not require anything in the body. Only add the fields you want to change to the body.

  • /api/hosts/[id] returns the entire (edited) host .
    • first_name (string, max:191) - The first name
    • last_name (text) - The last name.
    • description (string) - The host description.
    • picture (active_url) - The host picture.
❌ Errors:
  • Errors are equal to the create endpoint
  • No error will be trown when the body is empty
✔️ On succes:

200 OK - returns a JSON object with the updated host data.


🙅 Remove hosts (delete method)

The delete endpoint does not require anything in the body.

  • /api/hosts/[id] removes the host and returns it.
❌ Errors:

404 Not found - The requested host does not exist

✔️ On succes:

200 OK - returns a JSON object with the removed host.


😃 Follow hosts (post method)

The post endpoints require all body data as described.

  • /api/hosts/follow returns the data added to the DB.
    • host_id (required, uuid, exists in host table) - The host_id from the host you want to follow.
❌ Errors:
  • Error is only thrown when the user is unauthenticated or the host doesn't exist.
✔️ On succes:

201 Created - returns a JSON object with the followed host data.


😞 Unfollow hosts (delete method)

The delete endpoints does not require any body data.

  • /api/hosts/unfollow/{host_id} returns the unfollowed host data.
❌ Errors:
  • Error is only thrown when the user is unauthenticated or the host doesn't exist.
✔️ On succes:

201 Created - returns a JSON object with the unfollowed host data.


🧑‍🤝‍🧑 Get host followers (get method)

The get endpoints does not require any body data.

  • /api/hosts/followers/{host_id} returns the total followers of that host.
❌ Errors:
  • Error is only thrown when the user is unauthenticated or the host doesn't exist.
✔️ On succes:

201 Created - returns a JSON object with the total host followers.


Clone this wiki locally