Categories

Categories allow you to organize your posts. On this page, we'll dive into the different category endpoints you can use to manage categories programmatically. We'll look at how to query categories.

The category model

The category model contains all the information about your categories, such as their name, description, and avatar.

Properties

  • Name
    id
    Type
    string
    Description

    Unique identifier for the category.

  • Name
    publication_id
    Type
    number
    Description

    The id of the publication.

  • Name
    user_id
    Type
    number
    Description

    The id of the user who created the category.

  • Name
    name
    Type
    string
    Description

    The name of the category.

  • Name
    slug
    Type
    string
    Description

    The slug of the category.

  • Name
    description
    Type
    string
    Description

    The description of the category.

  • Name
    meta_title
    Type
    string
    Description

    The meta title of the category.

  • Name
    meta_description
    Type
    string
    Description

    The meta description of the category.

  • Name
    created_at
    Type
    timestamp
    Description

    The timestamp of comment create time.

  • Name
    updated_at
    Type
    timestamp
    Description

    The timestamp of comment update time.


GET/categories

List all categories

This endpoint allows you to retrieve a list of all your categories.

Optional attributes

  • Name
    limit
    Type
    integer
    Description

    Limit the number of categories returned.

Request

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

Response

{
  "meta": {
    "total": 1,
    "per_page": 20,
    "current_page": 1,
    "last_page": 1
  },
  "data": [
    {
      "id": 1,
      "user_id": 1,
      "publication_id": 3696,
      "name": "General",
      "slug": "general",
      "description": null,
      "created_at": "2023-03-05T09:53:13.000Z",
      "updated_at": "2023-03-05T09:53:13.000Z"
    }
  ]
}

GET/categories/{slug}

Get single category

This endpoint retrieves a single category by its slug.

Request

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

Response

{
  "category": {
    "id": 1,
    "user_id": 1,
    "publication_id": 3696,
    "name": "General",
    "slug": "general",
    "description": null,
    "created_at": "2023-03-05T09:53:13.000Z",
    "updated_at": "2023-03-05T09:53:13.000Z"
  }
}