Contents
On this page

Get Subject Tree - Plugixa Exam

GET /plugixa-exam/v1/subjects/tree

Get every subject at once, nested under its parent.

Scope subjects:read or lookups:read; the token’s user needs the subjects:view permission.

Note. The tree is not paged and has no meta. It holds live subjects only (trashed ones are left out), published or not, ordered by their path from the top level down.

Request

GET https://your-site.example/wp-json/plugixa-exam/v1/subjects/tree

Responses

200 OK. data is the list of top-level subjects, each with its children.

{
  "success": true,
  "data": [
    {
      "id": 3,
      "parent_id": 0,
      "path": "3",
      "level": 1,
      "code": "MATH",
      "title": "Mathematics",
      "slug": "mathematics",
      "description": "",
      "ordering": 1,
      "published": true,
      "created_at": "2026-11-10 14:05:00",
      "modified_at": "2026-11-10 14:05:00",
      "created_by": 1,
      "modified_by": 1,
      "deleted_at": null,
      "children": [
        {
          "id": 12,
          "parent_id": 3,
          "path": "3/12",
          "level": 2,
          "code": "MATH-ALG",
          "title": "Algebra",
          "slug": "algebra",
          "description": "",
          "ordering": 4,
          "published": true,
          "created_at": "2026-11-12 09:30:00",
          "modified_at": "2026-11-12 09:30:00",
          "created_by": 1,
          "modified_by": 1,
          "deleted_at": null,
          "children": []
        }
      ]
    }
  ]
}
Field Type Meaning
data[].id integer The subject’s id
data[].parent_id integer 0 for a top-level subject
data[].level integer Depth, from 1
data[].ordering integer Position among its siblings
data[].published boolean Whether the subject is published
data[].children array Its child subjects, each with the same fields and its own children. Empty for a leaf.

Every node carries the same fields as Get Subject, plus children.

Errors

Plus the errors every endpoint can return.

Examples

curl -s "https://your-site.example/wp-json/plugixa-exam/v1/subjects/tree" \
  -H "Authorization: Bearer $PLUGIXA_EXAM_TOKEN"
<?php
$ch = curl_init('https://your-site.example/wp-json/plugixa-exam/v1/subjects/tree');
curl_setopt_array($ch, [
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_HTTPHEADER     => [
        'Authorization: Bearer ' . getenv('PLUGIXA_EXAM_TOKEN'),
    ],
]);
$response = json_decode(curl_exec($ch), true);
curl_close($ch);
const response = await fetch('https://your-site.example/wp-json/plugixa-exam/v1/subjects/tree', {
  headers: {
    'Authorization': `Bearer ${process.env.PLUGIXA_EXAM_TOKEN}`,
  },
});
const { data } = await response.json();

Quick Links

Share