BlogPosts

Posts

Posts related to Blog

These endpoints allow you to create, read, update and delete posts. Posts are the main content of a blog and can be created by any profile.

These endpoints support pagination and sorting. Read more about these features here.

The Post model

PropTypeDefault
id
string
-
title
string
-
body
string
-
tags
Array<string>
-
media
object
-
created
string
-
updated
string
-
author
Profile
-

Filtering

You can filter based on an entry in the tags array by using the _tag query flag. You may only filter by one tag at a time.

PropTypeDefault
_tag
string
-

An example query filtering for posts with the tag my_tag:

GET/blog/posts/<name>?_tag=my_tag

All posts

GET/blog/posts/<name>

Retrieve all posts.

Response
{
  "data": [
    {
      "id": "string",
      "title": "string",
      "body": "string",
      "tags": ["string"],
      "media": {
        "url": "https://url.com/image.jpg",
        "alt": "string"
      },
      "created": "2022-09-04T08:08:38.830Z",
      "updated": "2022-09-04T08:08:38.830Z",
      "author": {
        "name": "string",
        "email": "string",
        "bio": "string",
        "avatar": {
          "url": "https://url.com/image.jpg",
          "alt": "string"
        },
        "banner": {
          "url": "https://url.com/image.jpg",
          "alt": "string"
        }
      }
    },
    {
      "id": "string",
      "title": "string",
      "body": "string",
      "tags": ["string"],
      "media": {
        "url": "https://url.com/image.jpg",
        "alt": "string"
      },
      "created": "2022-09-04T08:08:38.830Z",
      "updated": "2022-09-04T08:08:38.830Z",
      "author": {
        "name": "string",
        "email": "string",
        "bio": "string",
        "avatar": {
          "url": "https://url.com/image.jpg",
          "alt": "string"
        },
        "banner": {
          "url": "https://url.com/image.jpg",
          "alt": "string"
        }
      }
    }
    // ...
  ],
  "meta": {
    "isFirstPage": true,
    "isLastPage": true,
    "currentPage": 1,
    "previousPage": null,
    "nextPage": null,
    "pageCount": 1,
    "totalCount": 2
  }
}

Single post

GET/blog/posts/<name>/<id>

Retrieve a single post by its id.

Response
{
  "data": {
    "id": "string",
    "title": "string",
    "body": "string",
    "tags": ["string"],
    "media": {
      "url": "https://url.com/image.jpg",
      "alt": "string"
    },
    "created": "2022-09-04T08:08:38.830Z",
    "updated": "2022-09-04T08:08:38.830Z",
    "author": {
      "name": "string",
      "email": "string",
      "bio": "string",
      "avatar": {
        "url": "https://url.com/image.jpg",
        "alt": "string"
      },
      "banner": {
        "url": "https://url.com/image.jpg",
        "alt": "string"
      }
    }
  },
  "meta": {}
}

Create post

POST/blog/posts/<name>

Create a new post. Only the title property is required, but we recommend at least including the body and media properties as well.

Please note that the media.url property must be a fully formed URL that links to a live and publicly accessible image. The API will check the provided URL and if it cannot be accessed publicly you will receive a 400 Bad Request error response.

Request
{
  "title": "string", // Required
  "body": "string", // Optional
  "tags": ["string"], // Optional
  "media": {
    "url": "https://url.com/image.jpg",
    "alt": "string"
  } // Optional
}
Response
{
  "data": {
    "id": "string",
    "title": "string",
    "body": "string",
    "tags": ["string"],
    "media": {
      "url": "https://url.com/image.jpg",
      "alt": "string"
    },
    "created": "2022-09-04T16:21:02.042Z",
    "updated": "2022-09-04T16:21:02.042Z",
    "author": {
      "name": "string",
      "email": "string",
      "bio": "string",
      "avatar": {
        "url": "https://url.com/image.jpg",
        "alt": "string"
      },
      "banner": {
        "url": "https://url.com/image.jpg",
        "alt": "string"
      }
    }
  },
  "meta": {}
}

Update post

PUT/blog/posts/<name>/<id>

Update a post based on its id. This endpoint returns the updated post.

Please note that the media.url property must be a fully formed URL that links to a live and publicly accessible image. The API will check the provided URL and if it cannot be accessed publicly you will receive a 400 Bad Request error response.

Request
{
  "title": "string",
  "body": "string",
  "tags": ["string"],
  "media": {
    "url": "https://url.com/image.jpg",
    "alt": "string"
  }
}
Response
{
  "data": {
    "id": "string",
    "title": "string",
    "body": "string",
    "tags": ["string"],
    "media": {
      "url": "https://url.com/image.jpg",
      "alt": "string"
    },
    "created": "2022-09-04T16:21:02.044Z",
    "updated": "2022-09-04T16:21:02.044Z",
    "author": {
      "name": "string",
      "email": "string",
      "bio": "string",
      "avatar": {
        "url": "https://url.com/image.jpg",
        "alt": "string"
      },
      "banner": {
        "url": "https://url.com/image.jpg",
        "alt": "string"
      }
    }
  },
  "meta": {}
}

Delete post

DELETE/blog/posts/<name>/<id>

Delete a post based on its id.

Returns an empty 204 No Content response on success.