Choosing fields with select
/quotes, /assets,
/rwa and /dex/tokens take an optional
select: a comma-separated list of the row fields you want. Each row of items then carries
those fields and id, and nothing else.
bash
curl -H "X-Api-Key: <your-api-key>" \
"https://open-api.coinworldcap.com/openapi/v1/quotes?slug=bitcoin&select=price,percent_change"
json
{
"code": 0,
"message": "success",
"message_key": "SUCCESS",
"result": {
"items": [
{
"id": 1,
"price": "66079.916784987",
"percent_change": { "1h": "0.1", "24h": "1.2", "7d": "3.4", "30d": "5.6", "3m": "7.8", "1y": "9", "ytd": "1.1", "all": "2.2" }
}
],
"page": 1,
"total_page": 1,
"total": 1
}
}
- Only the rows are trimmed.
page,totalandtotal_pageare unchanged, and so are/dex/tokens'list,window,data_time,staleandfilters. Withoutselectthe response is exactly what it is today. idis always there, whether you name it or not. On/dex/tokensit is the token's own id, a string; to call the other/dexendpoints for a token, selectchain_slugandaddresstoo.- Names are the row fields in the endpoint's field table, top level only. A nested object or
array —
percent_change,windows,links,platforms,explorers— comes whole; there is nopercent_change.24h. - A name the endpoint's rows do not have is a
400, code40000: a typo, a dotted path, or a field of another endpoint (liquidityon/quotes). This is unlike other parameters, where a name we do not read is ignored (Check parameter names) — here an ignored name would answer rows of nothing butid. - At most 100 names, counted after splitting: empty items are dropped and a repeated name
counts each time. More is a
400. - Names are case-insensitive and surrounding spaces are trimmed.
select=with nothing in it is the same as noselect. - Sorting and filtering are unaffected. You can sort by a field you did not select; the rows
and their order are the same as without
select. - A field that may be absent stays absent. A row with no
rankhas none when you selectrank; it is not filled in asnull. - On
/assets,fieldscomes first.fieldsaddslinksorplatformsto the row, thenselecttrims it:fields=links&select=name,linksgivesid,nameandlinks. Selectinglinksorplatformswithout the matchingfieldsvalue is a400.fieldsitself is unchanged, and still ignores names it does not know.