mymolecules

Endpoint

GET/functions/v1/get_decode_compound_id

Find the compound ID and database name to use in a Decode filter. Query one compound name or ID; unclear queries return suggestions for clarification.

2026-07-10 is the newest public version. Send it in mymolecules-api-version with each lookup. Without the header, this endpoint uses a legacy response format. An unsupported version returns HTTP 400 (unsupported_api_version).

For key setup and secure storage, see Authentication.

Request fields

FieldTypeDescription
qstringRequired query parameter. Send one compound name or numeric ID, for example caffeine or 2987. Leading and trailing whitespace is ignored; an empty or whitespace-only query returns HTTP 400 (invalid_request). URL-encode names containing spaces or special characters. There is no batch, pagination or JSON request body.

Request examples

By name

GET /functions/v1/get_decode_compound_id?q=caffeine

By ID

GET /functions/v1/get_decode_compound_id?q=2987

Response fields

The result is returned directly with HTTP 200. There is no job ID, callback or polling step.

FieldTypeDescription
data.statusstringresolved when one compound can be identified, otherwise needs_clarification. Both return HTTP 200; this is a direct result, not a job status.
data.compound_idstringPresent only when resolved. Numeric compound identifier returned as a string. Pass it to Decode in compound_identifier_ids.
data.canonical_namestringPresent only when resolved. The compound’s name in our molecular database.
data.reasonstringPresent only when needs_clarification. ambiguous means several candidates are too similar to choose reliably. low_confidence means no candidate is a confident match.
data.suggestionsobject[]Present only when needs_clarification. Up to 10 candidates for ambiguous queries or up to 3 for low_confidence. May be empty. Ask the person to choose or make the query more specific; do not automatically treat the first suggestion as a resolved match.
data.suggestions[].compound_idstringNumeric ID of a suggested compound. Query this ID to confirm the selected compound.
data.suggestions[].canonical_namestringDatabase name to display when asking which compound was intended.
meta.request_idstringRequest identifier. Save it when investigating an issue or contacting support.
meta.api_versionstringThe dated API version used for this response.

Response examples

Resolved · HTTP 200

{
  "data": {
    "status": "resolved",
    "compound_id": "2987",
    "canonical_name": "caffeine"
  },
  "meta": {
    "request_id": "req_...",
    "api_version": "2026-07-10"
  }
}

Needs clarification · HTTP 200 (illustrative)

{
  "data": {
    "status": "needs_clarification",
    "reason": "ambiguous",
    "suggestions": [
      {
        "compound_id": "2414",
        "canonical_name": "alpha-tocopherol"
      },
      {
        "compound_id": "2870",
        "canonical_name": "beta-tocopherol"
      }
    ]
  },
  "meta": {
    "request_id": "req_...",
    "api_version": "2026-07-10"
  }
}

Use the result in Decode

When data.status is resolved, pass data.compound_id in Decode’s compound_identifier_ids array. Both strings and integers are accepted.

{
  "compound_identifier_ids": ["2987"]
}

This is a result-option fragment, not a complete Decode request. Add it to your Decode input.

  • An exact name or ID can resolve directly. Similar wording may also resolve, but broad terms can need clarification. Query one compound at a time.
  • needs_clarification is not a server failure. Make the query more specific, or let the person select a suggestion and query its ID. An empty suggestions array does not prove that the compound does not exist.
  • This endpoint requires access separate from Decode. Resolving an ID does not grant access to that compound in Decode or guarantee that a selected food has data for it.

Handle errors

CodeHTTP statusDescription
invalid_request400Supply a non-empty q query parameter.
unsupported_api_version400Use the documented date in mymolecules-api-version.
missing_api_key401Send your API key in x-api-key.
invalid_api_key401Check that the key is correct and active.
scope_not_allowed403The key needs access to Get Decode Compound ID. Decode access alone is not enough.
method_not_allowed405Use GET, not POST.
quota_exceeded429The key’s monthly limit has been reached. Wait for its reset or contact us; repeated requests will not help.
rate_limited429Slow down and follow Retry-After when supplied.
upstream_error502The lookup could not be completed. Retry with increasing delays; contact support with the request ID if the problem persists.
internal_error500 or 503The service is temporarily unavailable. Retry with increasing delays and a maximum retry limit.

Retry safely

  • After a network error or temporary server failure, retry the GET with increasing delays and a maximum retry limit. Follow Retry-After when supplied.
  • There is no job to poll and no Idempotency-Key is needed. Do not repeat needs_clarification unchanged expecting a more certain result; refine the query instead.

See the Errors & rate limits guide for the shared error envelope.

Code examples

curl --get 'https://api.mymolecules.de/functions/v1/get_decode_compound_id' \
  --data-urlencode 'q=caffeine' \
  -H "x-api-key: $MYMOLECULES_API_KEY" \
  -H 'mymolecules-api-version: 2026-07-10'

Use the examples on your server and set MYMOLECULES_API_KEY in its environment. Python requires requests (pip install requests). The example timeouts are client settings, not guaranteed response times.