Skip to main content
Including its metadata, subcategories, and associated statistics.
This endpoint returns comprehensive category information including subcategory details and object counts.

Endpoint

curl -X GET "https://api.g2cplatform.com/api/v2/object/{COMPANY_ID}/category/{CATEGORY_ID}" \
  -H "X-API-Key: YOUR_API_KEY" \
  -H "Content-Type: application/json"

Request

HTTP Method

GET

URL

https://api.g2cplatform.com/api/v2/object/{COMPANY_ID}/category/{CATEGORY_ID}

Path Parameters

ParameterTypeRequiredDescription
COMPANY_IDstring (UUID)Company identifier
CATEGORY_IDstring (UUID)Category identifier

Headers

X-API-Key: YOUR_API_KEY
Content-Type: application/json

Response

Success Response (200)

{
  "status": "success",
  "data": {
    "id": "cat_7f8a9b2c-4d5e-6f7g-8h9i-0j1k2l3m4n5o",
    "name": "Electronics",
    "status": "active",
    "imageId": "img_1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p",
    "description": "Electronic devices and components including smartphones, laptops, and IoT devices",
    "createDate": "2025-08-01T10:00:00Z",
    "subcategories": [
      {
        "id": "sub_8g9h0i1j-2k3l-4m5n-6o7p-8q9r0s1t2u3v",
        "name": "Smartphones",
        "status": "active",
        "imageId": "img_2b3c4d5e-6f7g-8h9i-0j1k-2l3m4n5o6p7q",
        "createDate": "2025-08-01T11:00:00Z",
        "objectsCount": 15
      },
      {
        "id": "sub_9h0i1j2k-3l4m-5n6o-7p8q-9r0s1t2u3v4w",
        "name": "Laptops",
        "status": "active",
        "imageId": null,
        "createDate": "2025-08-01T12:00:00Z",
        "objectsCount": 8
      }
    ],
    "files": [
      {
        "id": "file_1a2b3c4d-5e6f-7g8h-9i0j-1k2l3m4n5o6p",
        "name": "category_template.pdf",
        "title": "Electronics Category Template",
        "mimeType": "application/pdf",
        "uploadDate": "2025-08-01T15:00:00Z"
      }
    ],
    "statistics": {
      "totalSubcategories": 2,
      "totalObjects": 23,
      "activeSubcategories": 2,
      "lastObjectCreated": "2025-08-02T09:15:00Z"
    }
  },
  "timestamp": "2025-08-02T10:30:00Z"
}

Category Properties

FieldTypeDescription
idstring (UUID)Unique category identifier
namestringCategory name
statusstringCategory status (active, delisted, removed)
imageIdstring | nullAssociated image identifier
descriptionstringCategory description
createDatestring (ISO 8601)Category creation timestamp
subcategoriesarrayArray of subcategory objects
filesarrayArray of associated files
statisticsobjectCategory statistics

Error Responses

404 Not Found

{
  "error": "Category not found",
  "code": "CATEGORY_NOT_FOUND",
  "timestamp": "2025-08-02T10:30:00Z"
}

401 Unauthorized

{
  "error": "Invalid or missing API key",
  "code": "UNAUTHORIZED",
  "timestamp": "2025-08-02T10:30:00Z"
}

Use Cases

Category Overview

async function getCategoryOverview(companyId, categoryId) {
  const response = await fetch(
    `https://api.g2cplatform.com/api/v2/object/${companyId}/category/${categoryId}`,
    {
      headers: { 'X-API-Key': 'YOUR_API_KEY' }
    }
  );

  const category = await response.json();

  console.log(`Category: ${category.data.name}`);
  console.log(`Status: ${category.data.status}`);
  console.log(`Subcategories: ${category.data.statistics.totalSubcategories}`);
  console.log(`Total Objects: ${category.data.statistics.totalObjects}`);

  return category.data;
}

Category Navigation

async function buildCategoryNavigation(companyId, categoryId) {
  const category = await getCategoryOverview(companyId, categoryId);

  const navigation = {
    category: {
      id: category.id,
      name: category.name,
      description: category.description
    },
    subcategories: category.subcategories.map(sub => ({
      id: sub.id,
      name: sub.name,
      objectCount: sub.objectsCount,
      imageUrl: sub.imageId ? `/api/v2/object/${companyId}/file?FILE_ID=${sub.imageId}` : null
    }))
  };

  return navigation;
}

Next Steps