Posts

Posts are collection of post. On this page, we'll dive into the different post endpoints you can use to manage posts programmatically. We'll look at how to query, posts.

The post model

The post model contains all the information about your posts, including tags, the post's name, description, and avatar.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the post.

  • Name
    author_id
    Type
    number
    Description

    The id of the author.

  • Name
    publication_id
    Type
    number
    Description

    The id of the publication.

  • Name
    title
    Type
    string
    Description

    The title of the post.

  • Name
    excerpt
    Type
    string
    Description

    The excerpt of the post.

  • Name
    content
    Type
    string
    Description

    The HTML content of the post.

  • Name
    content_text
    Type
    string
    Description

    The text content of the post.

  • Name
    featured_image
    Type
    string
    Description

    Featured image URL of the post.

  • Name
    status
    Type
    string
    Description

    Publish or Draft status of the post.

  • Name
    featured_image
    Type
    string
    Description

    Featured image URL of the post.

  • Name
    post_type
    Type
    string
    Description

    Type of the post. (Post or Page)

  • Name
    meta_title
    Type
    string
    Description

    Meta title of the post.

  • Name
    meta_description
    Type
    string
    Description

    Meta description of the post.

  • Name
    featured
    Type
    number
    Description

    If the post is featured.

  • Name
    created_at
    Type
    timestamp
    Description

    The timestamp of post create time.

  • Name
    updated_at
    Type
    timestamp
    Description

    The timestamp of post update time.

  • Name
    published_at
    Type
    timestamp
    Description

    The timestamp of post publish time.

  • Name
    deleted_at
    Type
    timestamp
    Description

    The timestamp of post deleted time. (Only applicable for trashed posts)

  • Name
    reading_time
    Type
    number
    Description

    The reading time of the post.

  • Name
    tags
    Type
    array
    Description

    List of associated tags to the post.

  • Name
    author
    Type
    object
    Description

    The post author details.


GET/posts

List all posts

This endpoint allows you to retrieve a paginated list of all your posts. By default, a maximum of 20 posts are shown per page.

Optional attributes

  • Name
    limit
    Type
    integer
    Description

    Limit the number of posts returned.

  • Name
    draft
    Type
    boolean
    Description

    Only show posts that are in draft.

Request

GET
/v1/posts
curl -G https://api.bloghunch.com/app/{subdomain}/posts \
  -H "Authorization: Bearer {token}" \
  -d limit=10

Response

{
  "posts": {
    "meta": {
      "total": 23,
      "per_page": 10,
      "current_page": 1,
      "last_page": 3,
      "first_page": 1,
      "first_page_url": "/?page=1",
      "last_page_url": "/?page=3",
      "next_page_url": "/?page=2",
      "previous_page_url": null
    },
    "data": [
      {
        "id": 406856,
        "author_id": 1,
        "publication_id": 3696,
        "title": "Post test 1",
        "excerpt": null,
        "slug": "post-test-1",
        "content": "<p>test 1</p>",
        "content_text": "test 1",
        "featured_image": null,
        "status": "publish",
        "canonical_url": null,
        "post_type": "post",
        "meta_title": null,
        "meta_description": null,
        "featured": 0,
        "toc": 1,
        "published_at": "2023-03-07T22:44:29.000+05:30",
        "deleted_at": null,
        "created_at": "2023-03-07T22:44:20.000+05:30",
        "updated_at": "2023-03-07T22:44:29.000+05:30",
        "reading_time": 1,
        "author": {
          "id": 1,
          "name": "Subham Mitra",
          "tagline": "Full stack javascript developer",
          "avatar": "VQZOo1GnjkAdsqaW.webp"
        },
        "tags": [
          {
            "id": 66,
            "name": "faq",
            "slug": "faq"
          }
        ]
      }
    ]
  }
}

GET/posts/{slug}

Get single post

This endpoint allows you to retrieve a single post.

Request

GET
/v1/posts
curl -G https://api.bloghunch.com/app/{subdomain}/posts/{slug} \
  -H "Authorization: Bearer {token}"

Response

{
  "post": {
    "id": 406856,
    "author_id": 1,
    "publication_id": 3696,
    "title": "Post test 1",
    "excerpt": null,
    "slug": "post-test-1",
    "content": "<p>test 1</p>",
    "content_text": "test 1",
    "featured_image": null,
    "status": "publish",
    "canonical_url": null,
    "post_type": "post",
    "meta_title": null,
    "meta_description": null,
    "featured": 0,
    "toc": 1,
    "published_at": "2023-03-07T22:44:29.000+05:30",
    "deleted_at": null,
    "created_at": "2023-03-07T22:44:20.000+05:30",
    "updated_at": "2023-03-07T22:44:29.000+05:30",
    "reading_time": 1,
    "schema": "<script type=\"application/ld+json\" class=\"bh-schema-graph\">{\n            \"@context\":\"https://schema.org\",\n            \"@graph\":[\n                {\n                    \"@type\":\"WebSite\",\n                    \"@id\":\"https://scode/#website\",\n                    \"url\":\"https://scode\",\n                    \"name\":\"MotoHub\",\n                    \"description\":\"test 1\",\n                    \"potentialAction\":[\n                        {\n                            \"@type\":\"SearchAction\",\n                            \"target\":{\n                                \"@type\":\"EntryPoint\",\n                                \"urlTemplate\":\"https://scode/?s={search_term_string}\"\n                            },\n                            \"query-input\":\"required name=search_term_string\"\n                        }\n                    ],\n                    \"inLanguage\":\"en\"\n                },\n                {\n                    \"@type\":\"ImageObject\",\n                    \"@id\":\"https://scode/post-test-1/#primaryimage\",\n                    \"inLanguage\":\"en\",\n                    \"url\":\"https://cdn.bloghunch.com/uploads/\",\n                    \"contentUrl\":\"https://cdn.bloghunch.com/uploads/\",\n                    \"width\":0,\n                    \"height\":0\n                },\n                {\n                    \"@type\":\"WebPage\",\n                    \"@id\":\"https://scode/post-test-1/#webpage\",\n                    \"url\":\"https://scode/post-test-1\",\n                    \"name\":\"Post test 1\",\n                    \"isPartOf\":{\n                        \"@id\":\"https://scode/#website\"\n                    },\n                    \"primaryImageOfPage\":{\n                        \"@id\":\"https://scode/post-test-1/#primaryimage\"\n                    },\n                    \"datePublished\":\"2023-03-07T22:44:20.000+05:30\",\n                    \"dateModified\":\"2023-03-07T22:44:29.000+05:30\",\n                    \"author\":{\n                        \"@id\":\"https://scode/profile/1\"\n                    },\n                    \"description\":\"test 1\",\n                    \"breadcrumb\":{\n                        \"@id\":\"https://scode/post-test-1/#breadcrumb\"\n                    },\n                    \"inLanguage\":\"en\",\n                    \"potentialAction\":[\n                        {\n                            \"@type\":\"ReadAction\",\n                            \"target\":[\n                                \"https://scode/post-test-1\"\n                            ]\n                        }\n                    ]\n                },\n                {\n                    \"@type\":\"BreadcrumbList\",\n                    \"@id\":\"https://scode/post-test-1/#breadcrumb\",\n                    \"itemListElement\":[\n                        {\n                            \"@type\":\"ListItem\",\n                            \"position\":1,\n                            \"name\":\"Blog\",\n                            \"item\":\"https://scode\"\n                        },\n                        {\n                            \"@type\":\"ListItem\",\n                            \"position\":2,\n                            \"name\":\"Post test 1\"\n                        }\n                    ]\n                },\n                {\n                    \"@type\":\"Person\",\n                    \"@id\":\"https://scode/profile/1\",\n                    \"name\":\"Subham Mitra\",\n                    \"sameAs\":[\n                        \"https://scode\"\n                    ]\n                }\n            ]\n        }</script>",
    "publication": {
      "id": 3696,
      "name": "MotoHub",
      "subdomain": "scode",
      "domain": null
    },
    "author": {
      "id": 1,
      "name": "Subham Mitra",
      "tagline": "Full stack javascript developer",
      "avatar": "VQZOo1GnjkAdsqaW.webp"
    },
    "tags": [
      {
        "id": 66,
        "name": "faq",
        "slug": "faq"
      }
    ]
  }
}