質問

The xively (Cosm) web interface issues the following function for averaged historical datapoints

// For averaged historical datapoints
https://www.xively.com/feeds/<feedId>/datastreams/Humidity/graph.json&duration=21600seconds&interval=30&limit=1000&find_previous=true&function=average

I would like to fetch averaged historical data points (That is if there are multiple samples within the interval I am asking then return an averaged rollup as representative point of the interval) using Xively REST API

However this seems to return the raw data points (They just pick one datapoint to represent the sample interval)

https://api.xively.com/v2/feeds/127181539.json?datastreams=TEMP&duration=1month&interval=21600&limit=200&function=average

So questions

1) How can I return averaged data points like the Xively web interface? what parameter is needed for feed API call?

2) Does anyone know about the parameter interval_type? I have read what is here (https://xively.com/dev/docs/api/quick_reference/historical_data/) about 50 times now but I still don't get it!

Update

  1. function=sum as well as function=average works for /datastreams/TEMP.json endpoint. Also, they are discrete by default.
  2. The function=average does not works with /feeds/feed_id.json endPoint. Maybe a Bug?
役に立ちましたか?

解決

If you've got "function=average" (which you have) as a query parameter, then the points you get back should be bucketed to the interval you specified (21600 seconds / 6 hours). Each point represents the average value for that period.

It might be worth making this query against the datastreams endpoint though, e.g.

https://api.xively.com/v2/feeds/127181539/datastreams/TEMP.json?duration=1month&interval=21600&limit=200&function=average

Hope this helps!

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top