Skip to content

kwasimbnyarko/blog-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

blog-api

An API for a blog service that allows users to create, view, update and delete posts without authorization.

No sign-ups required. Create a post right away with a username and some text.

This api could be used to for a web app like Telegraph. (👈🏾 Click on the link for context if necessary)

This Project was built as a submission for a Slightly Techie Network Challenge

API Documentation

Main URL: https://blog-api-kf6i.onrender.com/api/

Create Post

End Point: /post
Method: POST
Request Body:

{
    "username" : "mj",
    "title":"on beefs",
    "text" : "i took that personally"
}

Response:201 Created

{
    "success" : "post created"
}

View Post

End Point: /post/:postId
Method: GET
Example Request: /post/649c20f10f9ddfa97a24ef48
Response:200 OK

[
    {
        "Id": "649c20f10f9ddfa97a24ef48",
        "username": "mj",
        "title": "on beefs",
        "text": "i took that personally",
        "created_At": "2023-06-28T12:00:49Z",
        "updated_At": "2023-06-28T12:00:49Z",
        "post_id": "649c20f10f9ddfa97a24ef48"
    }
]

View All Posts From A User

End Point: /post/user/:username
Method: GET
Example Request: /post/user/mj
Response:200 OK

[
    {
        "Id": "649c20f10f9ddfa97a24ef48",
        "username": "mj",
        "title": "on beefs",
        "text": "i took that personally",
        "created_At": "2023-06-28T12:00:49Z",
        "updated_At": "2023-06-28T12:00:49Z",
        "post_id": "649c20f10f9ddfa97a24ef48"
    },
    {
        "Id": "649c24ad0f9ddfa97a24ef4a",
        "username": "mj",
        "title": "on kids",
        "text": "f*ck 'em kids",
        "created_At": "2023-06-28T12:16:45Z",
        "updated_At": "2023-06-28T12:16:45Z",
        "post_id": "649c24ad0f9ddfa97a24ef4a"
    }
]

View All Posts

End Point: /post
Method: GET
Response:200 OK

[
    {
        "Id": "649c20f10f9ddfa97a24ef48",
        "username": "mj",
        "title": "on beefs",
        "text": "i took that personally",
        "created_At": "2023-06-28T12:00:49Z",
        "updated_At": "2023-06-28T12:00:49Z",
        "post_id": "649c20f10f9ddfa97a24ef48"
    },
    {
        "Id": "649b8651ac77266faa2fd853",
        "username": "ja",
        "title": "that interview",
        "text": "im fine in the west",
        "created_At": "2023-06-28T01:01:05Z",
        "updated_At": "2023-06-28T01:01:05Z",
        "post_id": "649b8651ac77266faa2fd853"
    },
    {
        "Id": "649c24ad0f9ddfa97a24ef4a",
        "username": "mj",
        "title": "on kids",
        "text": "f*ck 'em kids",
        "created_At": "2023-06-28T12:16:45Z",
        "updated_At": "2023-06-28T12:16:45Z",
        "post_id": "649c24ad0f9ddfa97a24ef4a"
    }
]

Update Post

End Point: /post/:postId
Method: PUT
Example Request:/post/649b8632ac77266faa2fd851

{
    "username":"tidylearner",
    "title":"alomo gyata",
    "text":"me na me de me ho aba nea mo p3 biaa mo nfa ny3 me"
}

Set unrequired fields to ""
An example for updating just title and text

{
    "username":"",
    "title" : "RW",
    "text" : "real wai"
}

Response:200 OK

{
    "success" : "post updated"
}

Delete Post

End Point: /post/:postId
Method: DELETE
Example Request:/post/649b8632ac77266faa2fd851
Response:200 OK

{
    "success" : "post deleted"
}

About

An API for a blog that allows users to create, view, update and delete posts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages