Skip to content

totask Blog API Documentation

Blog Routes

All blog-related endpoints are prefixed with /blog.

Create Blog Post

Endpoint: POST /blog/create

Description: Creates a new blog post.

Request Body:

  • Text Fields:
    • title: Title of the blog post (required).
    • content: Content of the blog post (required).
  • File Field:
    • file: Upload a file (e.g., image, PDF) to accompany the blog post (optional).

Response:

  • 200 OK
    json
    {
      "_id": "blog_post_id",
      "title": "Title of the Blog Post",
      "content": "Content of the Blog Post",
      "fileUrl": "URL_of_uploaded_file"
    }

Update Blog Post

Endpoint: PUT /blog/:blogPostId

Description: Updates an existing blog post.

Request Body:

  • Text Fields:
    • title: Updated title of the blog post.
    • content: Updated content of the blog post.
  • File Field:
    • file: Updated file to accompany the blog post.

Response:

  • 200 OK
    json
    {
      "_id": "blog_post_id",
      "title": "Updated Title of the Blog Post",
      "content": "Updated Content of the Blog Post",
      "fileUrl": "URL_of_updated_file"
    }

Delete Blog Post

Endpoint: DELETE /blog/:blogPostId

Description: Deletes a blog post.

Response:

  • 204 No Content

Get Blog Post by ID

Endpoint: GET /blog/:blogPostId

Description: Retrieves a blog post by its ID.

Response:

  • 200 OK
    json
    {
      "_id": "blog_post_id",
      "title": "Title of the Blog Post",
      "content": "Content of the Blog Post",
      "fileUrl": "URL_of_uploaded_file"
    }

Get All Blog Posts

Endpoint: GET /blog/posts

Description: Retrieves all blog posts.

Response:

  • 200 OK
    json
    [
      {
        "_id": "blog_post_id",
        "title": "Title of the Blog Post",
        "content": "Content of the Blog Post",
        "fileUrl": "URL_of_uploaded_file"
      },
      {
        "_id": "another_blog_post_id",
        "title": "Title of Another Blog Post",
        "content": "Content of Another Blog Post",
        "fileUrl": "URL_of_another_uploaded_file"
      },
      ...
    ]