Get documents by id and/or datatype

Get documents directly from Elasticsearch, by id and/or document type.

Fetches one or more documents directly from the search index by datatype and/or IDs. Supports field filtering, aggregations, and sorting. This is the public endpoint — it does not require API authentication.

Request

POST /documents/public

Headers

HeaderValue
Content-Typeapplication/json
X-Makaira-InstanceYour Makaira instance identifier

Request Body

FieldTypeRequiredDescription
datatypestringYesDocument type to retrieve. Note: makaira-product fetches variants and returns them with datatype: makaira-product; makaira-productgroup fetches products and returns them with datatype: makaira-productgroup.
constraintsobjectYesMust include query.language (language code). Optionally includes query.attribute_ids to filter by attribute IDs.
idsarrayNoArray of document IDs to fetch. If omitted or empty, returns all documents of the given datatype (use with caution — can produce large responses).
fieldsarrayNoArray of field names to include in the response. Defaults to all public fields from the whitelist.
includeContentbooleanNoWhen true, includes full document content.
aggregationsobjectNoActive filter selections.
sortingobjectNoSorting configuration.

Example Request — Fetch specific documents

{
  "datatype": "makaira-productgroup",
  "ids": ["product-123", "product-456"],
  "constraints": {
    "query.language": "de"
  }
}

Example Request — Fetch with field filter

{
  "datatype": "makaira-productgroup",
  "constraints": {
    "query.language": "de"
  },
  "fields": ["title", "price", "ean"],
  "ids": ["product-789"]
}

Response

Returns a JSON array of document objects. Documents not found are omitted.

Response Body

Each document object contains the requested fields under fields and meta information at the root level.

FieldTypeDescription
idstringDocument identifier.
fieldsobjectRequested document fields.
datatypestringThe resolved document type (may differ from requested, see datatype notes above).

Error Responses

StatusDescription
500Malformed request. Common causes: missing datatype, missing constraints, missing query.language, or requesting fields/attributes not on the public whitelist.
Body Params
string
required

Datatype of the documents to retrieve.

Special cases:

  • makaira-product will retrieve documents with datatype variant
    (datatype in the response will be makaira-product)
  • makaira-productgroup will retrieve documents with datatype product
    (datatype in the response will be makaira-productgroup)
  • variant will retrieve documents with datatype variant but the
    datatype in the response will be makaira-product
  • product will retrieve documents with datatype product but the
    datatype in the response will be makaira-productgroup
ids
array of strings

The ids of the documents to retrieve.

If this array is undefined or empty then you get all documents of the given datatype.
Be careful, this can produce very large responses.

ids
boolean

If this is set to true, then the response will contain the content of the documents.

fields
array of strings

Filter for the document fields to retrieve.

If not defined or empty then you will get all public fields that are whitelisted on the details page.

You can not use this to get fields that are not whitelisted.

fields
aggregations
object

List of selected values to filter for.

sorting
object
constraints
object
required

Use this to specify the language and filter the attributes.

Headers
string
required

Makaira Instance ID

Responses
200

Array with documents.

Language
Credentials
Bearer
URL
LoadingLoading…
Response
Click Try It! to start a request and see the response here! Or choose an example:
application/json