API select: Help removing data from response

Hi,

I’d like to reduce the output I receive when using the API to query my InfluxDB.

Here’s my current method/select query to get the data:

curl --insecure --get https://IPADDRESSHERE:8086/query?db=DATABASEHERE --header “Authorization: Token TOKENHERE” --data-urlencode “q=SELECT last(value) FROM DATABASEHERE.autogen.MEASUREMENTHERE WHERE time > now() -3s”

Here’s the output:

{“results”:[{“statement_id”:0,“series”:[{“name”:“MEASUREMENTHERE”,“columns”:[“time”,“last”],“values”:[[“2023-03-29T13:28:36Z”,4]]}]}]}

What I’d like to get is just the ‘4’ in response, or at least something a little less that I can then work on.

Is there a way to tweak the query to reduce the output?

Found a method using a Linux package called ‘jq’.

The curl results need piping to:

| jq '.results[].series[].values[][1]'

Which gives me:

4

Hope that helps someone else in the future

Hello @olliecampbell,
Thanks for sharing your solution!!