Pages

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

The page model

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

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the page.

  • 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 page.

  • Name
    excerpt
    Type
    string
    Description

    The excerpt of the page.

  • Name
    content
    Type
    string
    Description

    The HTML content of the page.

  • Name
    content_text
    Type
    string
    Description

    The text content of the page.

  • Name
    featured_image
    Type
    string
    Description

    Featured image URL of the page.

  • Name
    status
    Type
    string
    Description

    Publish or Draft status of the page.

  • Name
    featured_image
    Type
    string
    Description

    Featured image URL of the page.

  • Name
    page_type
    Type
    string
    Description

    Type of the page. (Page or Page)

  • Name
    meta_title
    Type
    string
    Description

    Meta title of the page.

  • Name
    meta_description
    Type
    string
    Description

    Meta description of the page.

  • Name
    featured
    Type
    number
    Description

    If the page is featured.

  • Name
    created_at
    Type
    timestamp
    Description

    The timestamp of page create time.

  • Name
    updated_at
    Type
    timestamp
    Description

    The timestamp of page update time.

  • Name
    published_at
    Type
    timestamp
    Description

    The timestamp of page publish time.

  • Name
    deleted_at
    Type
    timestamp
    Description

    The timestamp of page deleted time. (Only applicable for trashed pages)

  • Name
    reading_time
    Type
    number
    Description

    The reading time of the page.

  • Name
    tags
    Type
    array
    Description

    List of associated tags to the page.

  • Name
    author
    Type
    object
    Description

    The page author details.


GET/pages

List all pages

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

Optional attributes

  • Name
    limit
    Type
    integer
    Description

    Limit the number of pages returned.

  • Name
    draft
    Type
    boolean
    Description

    Only show pages that are in draft.

Request

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

Response

{
  "pages": {
    "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": "Page test 1",
        "excerpt": null,
        "slug": "page-test-1",
        "content": "<p>test 1</p>",
        "content_text": "test 1",
        "featured_image": null,
        "status": "publish",
        "canonical_url": null,
        "page_type": "page",
        "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/pages/{slug}

Get single page

This endpoint allows you to retrieve a single page.

Request

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

Response

{
  "page": {
    "id": 406856,
    "author_id": 1,
    "publication_id": 3696,
    "title": "Page test 1",
    "excerpt": null,
    "slug": "page-test-1",
    "content": "<p>test 1</p>",
    "content_text": "test 1",
    "featured_image": null,
    "status": "publish",
    "canonical_url": null,
    "page_type": "page",
    "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/page-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/page-test-1/#webpage\",\n                    \"url\":\"https://scode/page-test-1\",\n                    \"name\":\"Page test 1\",\n                    \"isPartOf\":{\n                        \"@id\":\"https://scode/#website\"\n                    },\n                    \"primaryImageOfPage\":{\n                        \"@id\":\"https://scode/page-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/page-test-1/#breadcrumb\"\n                    },\n                    \"inLanguage\":\"en\",\n                    \"potentialAction\":[\n                        {\n                            \"@type\":\"ReadAction\",\n                            \"target\":[\n                                \"https://scode/page-test-1\"\n                            ]\n                        }\n                    ]\n                },\n                {\n                    \"@type\":\"BreadcrumbList\",\n                    \"@id\":\"https://scode/page-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\":\"Page 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"
      }
    ]
  }
}

POST/pages

Create a page

This endpoint allows you to create a new page programmatically.

Required attributes

  • Name
    title
    Type
    string
    Description

    The title of the page (required if content is empty).

  • Name
    content
    Type
    string
    Description

    The HTML content of the page (required if title is empty).

Optional attributes

  • Name
    slug
    Type
    string
    Description

    A custom slug for the page.

  • Name
    excerpt
    Type
    string
    Description

    A brief excerpt for the page.

  • Name
    status
    Type
    string
    Description

    The status of the page (draft or publish).

  • Name
    category
    Type
    number
    Description

    The ID of the category.

  • Name
    tags
    Type
    array
    Description

    An array of tag IDs.

  • Name
    featured
    Type
    boolean
    Description

    Whether the page is featured.

Request

curl -X POST https://api.bloghunch.com/app/{subdomain}/pages \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "My New Page",
    "content": "<p>This is my new page created via API.</p>",
    "status": "draft"
  }'

Response

{
  "status": "success",
  "message": "Page created",
  "page": {
    "id": 406857,
    "title": "My New Page",
    "slug": "my-new-page",
    "content": "<p>This is my new page created via API.</p>",
    "status": "draft"
  }
}

PUT/pages/{id}

Update a page

This endpoint allows you to update an existing page.

Optional attributes

  • Name
    title
    Type
    string
    Description

    The new title of the page.

  • Name
    content
    Type
    string
    Description

    The new HTML content of the page.

  • Name
    status
    Type
    string
    Description

    The status of the page (draft or publish).

Request

curl -X PUT https://api.bloghunch.com/app/{subdomain}/pages/{id} \
  -H "Authorization: Bearer {token}" \
  -H "Content-Type: application/json" \
  -d '{
    "title": "Updated Page Title"
  }'

Response

{
  "status": "success",
  "message": "Page updated",
  "page": {
    "id": 406857,
    "title": "Updated Page Title"
  }
}

DELETE/pages/{id}

Delete a page

This endpoint allows you to delete an existing page.

Request

curl -X DELETE https://api.bloghunch.com/app/{subdomain}/pages/{id} \
  -H "Authorization: Bearer {token}"

Response

{
  "status": "success",
  "message": "Page deleted"
}