Contains information about the signup and signin, /signup API helps you create an account to get started and the /login endpoint signs the user in.
POST
/signup
/signup endpoint helps you create an account to get started.
POST
/login
/login endpoint signs the user in.
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/signup' \
--header 'Content-Type: application/json' \
--data-raw '{
"email": "s********@gmail.com",
"username": "****",
"password": "*******"
}'
Response format
Placing an API call to the signup endpoint returns a response that contains your set username, email, and token.
{
"status": "success",
"message": {
"username": "xxxx",
"email": "[email protected]",
"token": "ey***********G8w"
}
}
Response schema
Item | Description | Data type | Required/Optional |
---|---|---|---|
username | an identification used by a person with access to an online service | string | required |
messages distributed by electronic means | string | required | |
token | an object which represents the right to perform some operation | string | required |
Request format (CURL)
--header 'Content-Type: application/json' \
--data '{
"username": "****",
"password": "*********"
}'
Response format
{
"status": "success",
"message": {
"username": "xxxx",
"email": "[email protected]",
"token": "ey*********1E"
}
}
Response schema
Item | Description | Data type | Required/Optional |
---|---|---|---|
username | an identification used by a person with access to an online service | string | required |
messages distributed by electronic means | string | required | |
token | an object which represents the right to perform some operation | string | required |
To fetch, delete and update information about a specific user using their “id”. You can track information on the user by entering the unique user id, as it returns all basic information such as the user’s email, name, bio, avatar, and password.
GET
/users/:id
DELETE
/users/:id
PATCH
/users/:id
Header parameter
Authorization: Bearer ey**************G8w
Path parameter
Path parameter | Description |
---|---|
:id | abbreviation for a specific user identification |
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/users/12' \
--header 'Authorization: Bearer ey**************G8w'
Response format
{
"status": "success",
"user": {
"id": 12,
"username": "xxxxxxxxxxx",
"email": "[email protected]",
"bio": null,
"avatar": null,
"password": "******"
}
}
**Response schema
Item | Description | Data type | Required/Optional |
---|---|---|---|
id | abbreviation for identification | integer | required |
username | an identification used by a person with access to an online service | string | required |
messages distributed by electronic means | string | required | |
bio | a biography or short profile of someone | string | optional |
avatar | an icon or figure representing a perticular person on internet forum | string | optional |
password | a string of characters,allows access to a computer system | string | required |
Request format (CURL)
curl --location --request DELETE 'https://blog-api-dcha.onrender.com/v1/users/12' \
--header 'Authorization: Bearer ey*************G8w'
Response format
{
"status": "success",
"message": {
"id: 2,
"username": "Duby"
"email": "**********@gmail.com",
"bio": null,
"avatar": null,
}
}
**Response schema
Item | Description | Data type | Required/Optional |
---|---|---|---|
id | abbreviation for identification | integer | required |
username | an identification used by a person with access to an online service | string | required |
messages distributed by electronic means | string | required | |
bio | a biography or short profile of someone | string | optional |
avatar | an icon or figure representing a perticular person on internet forum | string | optional |
/users/:id
Request format (CURL)
curl --location --request PATCH 'https://blog-api-dcha.onrender.com/v1/users/12' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ey*********G8w' \
--data '{
"username": "****",
"bio": ****,
"avatar": ****
}'
Response format
{
"status": "success",
"message": {
"id: 2,
"username": "Duby"
"email": "**********@gmail.com",
"bio": null,
"avatar": null,
}
}
**Response schema
Item | Description | Data type | Required/Optional |
---|---|---|---|
id | abbreviation for identification | integer | required |
username | an identification used by a person with access to an online service | string | required |
messages distributed by electronic means | string | required | |
bio | a biography or short profile of someone | string | optional |
avatar | an icon or figure representing a perticular person on internet forum | string | optional |
To get and fetch all post data. The response you receive can be further filtered through the query parameter.
GET
/posts
POST
/posts
GET
/posts/:id
PATCH
/posts/:id |
Header parameter
Authorization: Bearer ey**************G8w
Path parameter
Path parameter | Description |
---|---|
:id | abbreviation for a specific user identification |
/posts
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/posts' \
--header 'Authorization: Bearer ey*******G8w'
Response format
{
"status": "success",
"message": {
"postLength": 2,
"posts": [
{
"username": "batman",
"user_id": 11,
"id": 4,
"title": "The batman",
"content": "about movie review",
"thumbnail_url": "https://*********",
"updated_at": "2023-******"
},
{
"username": "batman",
"user_id": 11,
"id": 3,
"title": "The batman",
"content": "about movie review",
"thumbnail_url": "https://********",
"updated_at": "2023-*******Z"
}
]
}
}
/posts
Use the API to add a new post to the list of posts. The add posts endpoint uses the POST request method in this format.
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/posts' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ey*************G8w' \
--data '{
"title": "newman",
"content": "great movie",
"url": "https://*************fecb"
}'
Response format
{
"status": "success",
"message": "posted"
}
/posts/:id
This endpoint lets you filter posts by adding a specific post ID to the endpoint in this format.
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/posts/10' \
--header 'Authorization: Bearer ey******G8w'
**Response format**
```json
{
"username": "batman",
"user_id": 11,
"id": 3,
"title": "The batman",
"content": "about movie review",
"thumbnail_url": "https://*******",
"updated_at": "2023-******"
}
/posts/:id
Use this endpoint to update your posts by the post’s id. There are various options when it comes to updating posts. You can edit the post title, post content, or thumbnail.
Request format (CURL)
curl --location --request PATCH 'https://blog-api-dcha.onrender.com/v1/posts/5' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer ey**********G8w' \
--data '{
"content": "the batman first blog"
}'
Response format
{
"status": "success",
"message": "post updated"
}
To get a collection of usernames of those who have liked a post and to fetch number of likes on a post
GET
/posts/:id/like/usernames
GET
/posts/:id/like/count
GET
/posts/:id/like/user/:uid
/posts/:id/like/user/:uid
DELETE
/posts/:id/like/user/:uid
Header parameter
Authorization: Bearer ey**************G8w
Path parameter
Path parameter | Description |
---|---|
:id | abbreviation for a specific user identification |
:uid | a unique identifier is a numeric or alphanumeric integer, associated with a single entity within a given system |
/posts/:id/like/usernames
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/posts/3/like/usernames' \
--header 'Authorization: Bearer ey***********G8w'
Response format
{
"status": "success",
"message": []
}
posts/:id/like/count
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/posts/3/like/count' \
--header 'Authorization: Bearer eyJ************G8w'
Response format
{
"status": "success",
"message": "0"
}
posts/:id/like/user/:uid
Use this endpoint to find out if a user has liked a post or not. The likes endpoint requires two IDs: one if the post <id>
and the other is the user id <uid>
. The two IDs are integers and to make a successful call to the endpoint, you must replace them with the appropriate integer in the URL.
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/posts/5/like/user/20' \
--header 'Authorization: Bearer ey**********Vy1E'
Response format
{
"status": "success",
"message": false
}
posts/:id/like/user/:uid
posts/:id/like/user/:uid
This endpoint deletes a like for the user in the post with the given id. To place an API call to this endpoint, you need to replace <id>
, and <uid>
with the integer for the post identifier and user identifier respectively.
Request format (CURL)
curl --location --request DELETE 'https://blog-api-dcha.onrender.com/v1/posts/5/like/user/20' \
--header 'Authorization: Bearer ey***********G8w'
Response format
{
"status": "success",
"message": "like deleted"
}
GET
/posts/:id/comment
PATCH
/posts/:id/comment/user/:uid
DELETE
/posts/:id/comment/user/:uid
Header parameter
Authorization: Bearer ey**************G8w
Path parameter
Path parameter | Description |
---|---|
:id | abbreviation for a specific user identification |
:uid | a unique identifier is a numeric or alphanumeric integer, associated with a single entity within a given system |
/posts/:id/comment
Use this endpoint to retrieve comments on a specific post. The identifier required in the endpoint is the post identifier specific to the post you need data on.
Request format (CURL)
curl --location 'https://blog-api-dcha.onrender.com/v1/posts/5/comment' \
--header 'Authorization: Bearer ey**********Vy1E'
Response format
{
"status": "success",
"message": []
}
/posts/:id/comment/user/:uid
Querying this endpoint allows update or make changes to a comment on a post. To make an update on a specific post, you have to filter using resource parameters. In this case, the resource parameters are the user identifier <id>
and the post identifier <uid>
.
Request format
curl --location --request PATCH 'https://blog-api-dcha.onrender.com/v1/posts/5/comment/user/20' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer eyJ***********G8w' \
--data '{
"comment": "updated comment"
}'
Response format
{
"status": "success",
"message": "comment updated."
}
/posts/:id/comment/user/:uid
This endpoint deletes comments on a specific post. To determine the actual post where you want to delete a comment, you need to use the resource parameters, <id>
and <uid>
.
Request format (CURL)
curl --location --request DELETE 'https://blog-api-dcha.onrender.com/v1/posts/5/comment/user/20' \
--header 'Authorization: Bearer ey*************G8w'
Response format
{
"status": "success",
"message": "comment done"
}
Error codes | description |
---|---|
200 | OK |
400 | BAD REQUEST |
401 | UNAUTHORIZED |
403 | FORBIDDEN |
404 | NOT FOUND |
Everything worked as expected.
{
"status": "success",
"user": {
"id": 12,
"username": "xxxxxxxxxxx",
"email": "[email protected]",
"bio": null,
"avatar": null,
"password": "*****************************************************************r3lqO"
}
}
The request was unsuccessful, this is mostly as a result of missing parameters. It could be a query parameter or a resource parameter.
{
"status": {
"error": true,
"code": 400,
"type": "bad request",
"message": {
"description": "status has an incorrect data type. It should be -> integer",
"attribute": "status"
}
}
}
You get this error when the token you passed is invalid or you didn’t pass an authorization token at all
{
"status": "fail",
"message": "you are not logged in"
}
The bearer token passed doesn't have permissions to perform the request.
{
"status": {
"error": true,
"code": 403,
"type": "forbidden",
"message": "user is not authorized to access this User"
}
}
This means that the resource you are trying to call does not exist
{
"status": {
"error": true,
"code": 404,
"type": "not found",
"message": "User for id 11111111 was not found"
}
}