anyproto / anyproto/anytype-api

Batch fetch objects by ID

Open
#36 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
113
Forks
20
Avg merge
16m
Merged PRs (30d)
1

Description

Have you read a contributing guide?
  • I have read CONTRIBUTING.md
  • I have searched the existing requests and didn't find any that were similar
  • I have considered creating a pull request instead and want to proceed
Clear and concise description of the problem

When building MCP workflows that operate on lists of known objects (e.g., populating a daily briefing with specific tasks and commitments), there's no way to fetch multiple objects by ID in a single request.

Currently, fetching N objects requires N sequential GET /v1/spaces/{space_id}/objects/{object_id} calls, which is slow and inefficient for LLM agents.

I tested whether filters could provide a workaround:

{"conditions": [{"property_key": "id", "condition": "in", "objects": ["id1", "id2"]}]}

This returns 400 because id is not a filterable property (which makes sense—it's a primary key, not a property).

Suggested solution

Add a batch fetch endpoint:

Option A: GET with query parameter

GET /v1/spaces/{space_id}/objects/batch?ids=id1,id2,id3

Option B: POST with body

POST /v1/spaces/{space_id}/objects/batch
{"ids": ["id1", "id2", "id3"]}

Response would be an array of objects (or a map keyed by ID), with 404s for missing IDs handled gracefully (e.g., null in the array or omitted from the map).

Alternative

Continue making N sequential requests, but this significantly impacts agent performance when working with object lists.

Additional context

This came up while building a daily briefing automation that needs to fetch:

  • Multiple task objects linked from a project
  • Multiple meeting objects for a given day
  • Commitment objects referenced from various sources

Each of these currently requires iterating and fetching one-by-one.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the existing GET /v1/spaces/{space_id}/objects/{object_id} endpoint and the API's conventions for new endpoints and missing resources. Decide between the proposed GET and POST designs, then implement batch retrieval with graceful handling for missing IDs. Done means clients can fetch multiple known objects in one request and receive a documented response.

Written by the indexing model from the issue text.

Assessment

Tech stack
openapi
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.