Notion API v3 – nested database relations return only IDs, not full objects
0 reputation · 14 Sept 2021, 16:11 UTC
0 reputation · 14 Sept 2021, 16:11 UTC
Clarify how the Notion API v3 handles nested database relations when querying a page that contains a relation property.
The API returns the relation property as an array of page IDs, omitting the full property values of the related pages. Clients must perform separate queries to resolve these IDs.
Additional round‑trips increase latency and complexity for applications that build relational views. The documentation does not state whether this is intentional or an oversight, and no official issue tracker entry confirms the intended behavior.
34775 reputation · 15 Sept 2021, 00:05 UTC
The Notion API returns relation properties as an array of page IDs rather than expanded objects. This behavior is intentional and consistent with the API's design; there are currently no undocumented parameters or "deep load" flags to automatically expand nested relation objects into full page data within a single request.
To retrieve the full details of related pages without incurring excessive latency or hitting rate limits, developers should implement a batch-and-cache strategy rather than performing a request for every single ID encountered.
Retrieve a Page endpoint for each unique ID.Because each related page requires a separate API call, high-volume relational data can quickly trigger 429 Too Many Requests errors. To mitigate this, consider the following:
You can verify this behavior by executing a GET request to the /v1/databases/{database_id}/query endpoint. Inspect the properties object for any property of type relation; you will observe that the id field is present, but the properties of that related page are absent.
Diagnostic Detail Required: To provide a more optimized fetching strategy, please specify if you are retrieving relations for a single page or aggregating relations across a large result set of multiple pages.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 15 Sept 2021, 03:59 UTC
The Notion API v3 always returns relation properties as an array of objects containing only the id field, regardless of whether the relation is single‑ or multi‑select. While there is no server‑side expand parameter, you can retrieve the full page objects for all related items in a single request by querying the target database with a relation filter that matches the IDs you received.
POST /v1/databases/{target_database_id}/query with a filter: { "property": "Relation", "relation": { "contains": "{page_id}" } } (repeat for each ID or use the in operator if supported)./v1/pages/{id} calls.This approach reduces round‑trips and helps stay within Notion’s rate limit of ~3 requests per second per integration, though you should still monitor for bursts and apply modest concurrency limits.