What is a category ID?

Category IDs are unique identifiers used to reference specific categories in your knowledge base when making API requests. To work effectively with the NeetoKB API, it’s important to know how to retrieve these IDs. You can do this programmatically by using the API to fetch all categories and their associated information.

Using the API Endpoint

The List all categories API endpoint allows you to retrieve a list of all categories in your workspace, including their IDs. This is particularly useful when you need to programmatically access or retrieve the IDs of all available categories.

Step-by-Step Instructions

1

Make the API request

Send a GET request to the List all categories API endpoint, including your API key in the request header.
2

Parse the response

The response will contain an array of categories with detailed information including id, name, count statistics, and nested subcategories.Example:
{
  "categories": [
    {
      "id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
      "name": "Getting Started",
      "description": "Essential guides to get you started",
      "sequence": 1,
      "parent_id": null,
      "depth": 0,
      "articles_count": 3,
      "categories_count": 2,
      "total_articles_count": 8,
      "url": "https://example.neetokb.com/categories/getting-started",
      "subcategories": [
        {
          "id": "b8e3d4f2-1a56-4c78-9012-345678901234",
          "name": "Quick Setup",
          "articles_count": 2,
          "categories_count": 0,
          "total_articles_count": 2
        }
      ],
      "ancestors": [],
      "children": ["b8e3d4f2-1a56-4c78-9012-345678901234"],
      "articles": [
        {
          "id": "f1a2b3c4-5d6e-7f8g-9h0i-1j2k3l4m5n6o",
          "url": "https://example.neetokb.com/articles/welcome",
          "title": "Welcome to NeetoKB",
          "created_at": "2024-01-15T10:30:00Z",
          "content": "Welcome to your knowledge base..."
        }
      ]
    },
    // ... rest of the categories
  ]
}
3

Extract the category ID

Here the category ID for the Getting Started category is:
  • ID: 3c90c3cc-0d44-4b50-8888-8dd25736052a
You can access the category information in your code from the response using:
// Get the first category's ID and metadata
const category = response.categories[0];
const categoryId = category.id;
const articlesCount = category.articles_count;
const totalArticles = category.total_articles_count;

// Find a specific category by name
const gettingStartedCategory = response.categories.find(category =>
  category.name === "Getting Started"
);

if (gettingStartedCategory) {
  const id = gettingStartedCategory.id;
  const subcategories = gettingStartedCategory.subcategories;
  const articles = gettingStartedCategory.articles;
}
The categories array contains all categories in your workspace with rich metadata:
  • Hierarchy: subcategories, ancestors, children, parent_id, depth show the category structure
  • Statistics: articles_count, categories_count, total_articles_count provide count information
  • Content: articles array includes embedded article objects for each category
  • Identification: UUID id is provided for referencing categories
If you have multiple categories, you may want to filter by name or other properties to find the specific category you need.