| Status: | Proposed |
|---|---|
| Date: | 2026-04-08 |
| Deciders: | API Working Group |
Some APIs return deeply nested JSON payloads (course structures, block trees, progress views). This makes payloads hard to parse, increases response size, and slows clients and automated agents.
- Provide a "minimal" representation option for complex resources:
- Query param example:
?view=minimalor?fields=....
- Query param example:
- Normalize/flatten overly nested structures where possible:
- Prefer references/IDs with follow-up endpoints over embedding entire trees.
- Document response shapes in OpenAPI, including minimal vs full variants.
- Deeply nested payloads: The course blocks API (
lms/djangoapps/course_api/blocks/views.py) returns a tree of blocks withrootandblocks(dict keyed by usage ID), each block containingid,type,display_name,children,student_view_data, etc. Full trees can be large and hard to parse. - Existing flexibility: Blocks API already supports
requested_fieldsandblock_types_filterto reduce payload; aview=minimalorfields=...convention would align with this ADR. - Modulestore/OLX:
openedx/core/djangoapps/olx_rest_api/views.pyreturns nested block OLX; providing a minimal (e.g. IDs + types only) view would help clients that only need structure.
Query params for minimal representation:
GET /api/courses/v1/blocks/<usage_id>/?depth=1&requested_fields=id,type,display_name
GET /api/course_structure/v1/?view=minimal
Response shape (minimal vs full):
// minimal (?view=minimal or ?fields=id,type,display_name,children)
{
"root": "block-v1:...",
"blocks": {
"block-v1:...": { "id": "...", "type": "chapter", "display_name": "Week 1", "children": ["..."] }
}
}
// full: same structure but with student_view_data, completion, block_counts, etc.Prefer IDs + follow-up over embedding:
GET /api/courses/v1/blocks/ → returns block IDs and types
GET /api/courses/v1/blocks/<id>/ → returns full block when needed
- Pros
- Improved performance and developer ergonomics.
- Easier integration for external services and AI agents.
- Cons / Costs
- Must maintain multiple representations; requires careful schema/versioning discipline.
- Start with endpoints called out in the standardization notes (course structure, contentstore index, xblock, progress).
- Measure payload size reduction and client performance improvements.
- “Hard-to-Parse Deeply Nested JSON” recommendation in the Open edX REST API standardization notes.