curl is enough to prove a key works. POST https://api.trendsapi.ai/api with a Bearer header and a JSON object. The response envelope stores the payload in body as a string. That string must be parsed a second time. jq does the second parse. A Makefile that ignores the HTTP status will treat a 429 as success. Read the key from an already-exported variable so the token never sits in shell history. Docs: the API reference. Caps: pricing. Steam board example notes: the Steam guide.

The four flags that matter

curl -sS --fail-with-body \
  -X POST "https://api.trendsapi.ai/api" \
  -H "Authorization: Bearer ${TRENDSAPI_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"mode":"get_top_trends","type":"Steam Most Played","limit":5}'

-sS silences the progress meter and still shows errors. The fail-with-body flag turns 401/429 into a non-zero exit. -X POST and the two -H lines are the contract. The -d object is a labeled sample, not a live pull.

Pipe body through jq twice

curl -sS --fail-with-body \
  -X POST "https://api.trendsapi.ai/api" \
  -H "Authorization: Bearer ${TRENDSAPI_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"mode":"get_growth","source":"google search","keyword":"bitcoin","percent_growth":["12M"]}' \
| jq -r '.body' \
| jq .

First jq unwraps the string. Second jq pretty-prints the inner object. jq '.body | fromjson' is the one-process form of the same idea.

Fail the shell on 401 and 429

Without fail-with-body, a 429 can look like an empty success in a Makefile. Check statusCode on 200 responses too. An inner error can still ride in a 200 envelope.

A one-liner for get_top_trends

curl -sS --fail-with-body -X POST "https://api.trendsapi.ai/api" \
  -H "Authorization: Bearer ${TRENDSAPI_API_KEY}" \
  -H "Content-Type: application/json" \
  -d '{"mode":"get_top_trends","type":"Google Trends","limit":5}' \
| jq '.body | fromjson'

No keyword on that mode. limit defaults to 25 and maxes at 200. offset pages. Current plan text: pricing.