Skip to content

Migration: Category API #550

@tenzinsamten

Description

@tenzinsamten

OpenPecha API:

GET /v2/categories?language=bo
Header Required Value
X-Application Yes webuddhist
Query Param Type Required Description
parent_id string No Parent category ID (omitted = root categories)
language string No Language code (default: bo)

Response (200):

[
  {
    "children": [],
    "description": null,
    "id": "rw8oWUd1WtwqeD2x0ZMSm",
    "parent_id": null,
    "title": { "bo": "མདོ།", "en": "Discourses", "zh": "經部" }
  }
]
Code Description
200 Categories retrieved successfully
400 Error with request
500 Internal server error

Replaces WeBuddhist API:

GET /api/v1/collections?language=en&skip=0&limit=10
Query Param Type Required Description
parent_id string | null No Filter by parent
language string | null No Language code
skip integer No Records to skip
limit integer No Records to return

Response (200):

{
  "parent": null,
  "pagination": { "total": 15, "skip": 0, "limit": 10 },
  "collections": [
    {
      "id": "695e046159c99585c95d3622",
      "pecha_collection_id": "rw8oWUd1WtwqeD2x0ZMSm",
      "title": "Discourses",
      "description": "",
      "language": "en",
      "slug": "Discourses",
      "has_child": false
    }
  ]
}
Code Description
200 Successful Response
422 Validation Error

Response Mapping:

WeBuddhist OpenPecha Notes
collections[].pecha_collection_id categories[].id Shared ID — use this to match, not WeBuddhist id
collections[].id Internal MongoDB ID, no OP equivalent
collections[].title categories[].title WeBuddhist: single string. OP: multilingual object { bo, en, zh }
collections[].description categories[].description Direct mapping (WeBuddhist: "", OP: null when empty)
collections[].has_child categories[].children WeBuddhist: boolean. OP: array of child IDs
collections[].language WeBuddhist Backend-only, not in OP
collections[].slug Deprecated
parent Not in OP
pagination.* Deprecated — OP returns all categories, no pagination
categories[].parent_id New field from OP

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions