A homepage strip of watched coins comes from the trending module, which returns the list under trendingList. The price and the 24-hour change sit together inside priceChange, not on the coin itself.
Send module=trending. Leaving the parameter off selects global_matric, and meta.module will not be trendingList. The other module values return different lists.
To access this endpoint, you must obtain an API key: Get your API key
Confirm the response is trendingList
After the call, meta.module should be trendingList. meta.total is the count stored for that module. The strip reads coins from body only when the module name matches.
Method: GET
Endpoint: https://api.mboum.com/v1/crypto/modules?module=trending
Documentation: crypto modules
import requests
url = "https://api.mboum.com/v1/crypto/modules"
headers = {"Authorization": "Bearer YOUR_API_KEY"}
params = {"module": "trending"}
response = requests.get(url, headers=headers, params=params)
response.raise_for_status()
payload = response.json()
if payload["meta"]["module"] != "trendingList":
raise SystemExit("unexpected module")
strip = []
for coin in payload["body"]:
change = coin["priceChange"]
strip.append({
"symbol": coin["symbol"],
"name": coin["name"],
"rank": coin["rank"],
"price": change["price"],
"change_24h": change["priceChange24h"],
})
print(strip)
Fill the strip from the nested 24-hour change
The excerpt is the one coin the file prints in full. The strip copies the nested price and priceChange24h. On this coin the 7-day and 30-day changes are the same number, so the strip does not plot those two windows as different moves.
{
"meta": {
"total": 10,
"module": "trendingList"
},
"body": [
{
"name": "CyberConnect",
"symbol": "CYBER",
"rank": 378,
"priceChange": {
"price": 3.9704376710966343,
"priceChange24h": -5.25190314,
"priceChange7d": 120.13555185,
"priceChange30d": 120.13555185,
"volume24h": 39253295.67980275,
"lastUpdate": "2023-08-17T17:31:00.000Z"
}
}
]
}
The file continues after that coin. These nested change fields belong to this trending list. A different module is a different request and does not reuse this row.
Learn more or explore other endpoints: crypto modules