curl -s https://api.example.com | jq '.data[0].id'

Category: Web App Development

curl -s https://api.example.com | jq '.data[0].id'

Pipe an API response into jq to extract a field

Fetches JSON from the API and pipes it to jq, which extracts the id of the first item in the data array. jq makes unstructured JSON responses readable and scriptable. Use -r with jq to print raw strings without quotes.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.