Core API

Decode API

Available

Decode turns everyday food input into structured food items, quantities, reusable Decode Food IDs and molecular nutrition output. It is the base layer for products that need to understand what a person ate beyond calories and macros.

Endpoint

POST/functions/v1/decode

Contract

Send mymolecules-api-version with 2026-07-10 to use the documented response contract.

{
  "data": {},
  "meta": {
    "request_id": "req_...",
    "api_version": "2026-07-10"
  }
}

Headers

Request

  • x-api-key required - Server-side API key for your integration.
  • mymolecules-api-version required 2026-07-10 - Use the latest stable API version: 2026-07-10.
  • Content-Type required application/json - Required for JSON request bodies.

Response

  • x-request-id required - Request identifier. Log this value when contacting support.
  • mymolecules-api-version required 2026-07-10 - The API contract version used for the response.
  • x-ratelimit-limit optional - Quota limit for the current key and window when quota data is available.
  • x-ratelimit-remaining optional - Remaining requests in the current quota window when quota data is available.
  • x-ratelimit-reset optional - ISO timestamp for the current quota window reset when quota data is available.
  • retry-after optional - Seconds to wait before retrying when the request is rate-limited or temporarily unavailable.

Inputs

  • input_mode: unstructured, structured or decode_id
  • Unstructured input with foodText, foodImage, foodVoice, foodImageRemaining or attachments; media fields accept data URLs or HTTP(S) URLs
  • Structured input with a non-empty items array
  • decode_id input with decode_food_id

Returns

  • 202 queued response with job_id and status_url
  • Status response with queued, processing, completed or failed
  • Completed food_detected result with recognized foods, reusable decode_food_id values and molecular measurements
  • Completed no_food_detected result with an empty items array when the input contains no food

Async pattern

Create the job with POST, then poll the same endpoint with job_id until the status is completed or failed.

  • Poll parameter: job_id
  • Status values: queued, processing, completed, failed

Error codes

  • missing_api_key
  • invalid_api_key
  • scope_not_allowed
  • quota_exceeded
  • invalid_json
  • invalid_request
  • validation_error
  • method_not_allowed
  • unsupported_api_version
  • job_not_found
  • backlog_high
  • upstream_timeout
  • upstream_error
  • internal_error

Request details

  • Use exactly one input mode. Do not mix decode_food_id with food text, images, voice or structured items.
  • Describe textual remaining information in foodText. Use foodImageRemaining only for a separate photo of what remained.
  • Optional compound_identifier_names or compound_identifier_ids can narrow molecular output to selected compounds.
  • Set include_compound_identifier_value or include_measurement_min_max only when those additional fields are needed.

Response details

  • Poll GET /functions/v1/decode?job_id=... until status is completed or failed.
  • Status polling returns result when available and error when a job fails.
  • Every completed result has type: food_detected or type: no_food_detected. No-food is a completed domain result, not a failed job.
  • no_food_detected always returns items: [] and error: null.
  • Molecular measurements include measurement_unit and matrix_unit; matrix_unit is an array because an aggregated result can use more than one food basis.
  • Use include_result=false or result=none on status requests when you only need the job state.

Operational notes

  • Requires x-api-key with the edge:decode scope.
  • POST usage is counted and rate-limit headers are returned when quota data is available.
  • Large media payloads should be sent only when needed; URLs or attachments are preferable for repeated workflows.

Examples

Request JSON

{
  "input_mode": "unstructured",
  "foodText": "Greek yogurt with blueberries, walnuts and honey"
}

Response JSON

{
  "data": {
    "job_id": "8a93f4...",
    "status": "queued",
    "status_url": "https://api.mymolecules.de/functions/v1/decode?job_id=8a93f4..."
  },
  "meta": {
    "request_id": "req_...",
    "api_version": "2026-07-10"
  }
}

Code examples

curl -X POST 'https://api.mymolecules.de/functions/v1/decode' \
  -H 'x-api-key: $MYMOLECULES_API_KEY' \
  -H 'mymolecules-api-version: 2026-07-10' \
  -H 'Content-Type: application/json' \
  --data '{  "input_mode": "unstructured",  "foodText": "Greek yogurt with blueberries, walnuts and honey"}'