If I use this URL: https://api.xively.com/v2/feeds/65673.json?datastreams=3
Xively returns this:
{ "id":65673,
"title":"Swimming Pool",
"private":"false",
"tags":["arduino","xbee"],
"description":"Monitors swimming pool conditions",
"feed":"https://api.xively.com/v2/feeds/65673.json",
"status":"live",
"updated":"2013-08-03T22:35:27.489534Z",
"created":"2012-07-02T00:23:57.518294Z",
"creator":"https://xively.com/users/scott216",
"version":"1.0.0",
"datastreams":[{
"id":"3",
"current_value":"76.20",
"at":"2013-08-03T22:35:27.247712Z",
"max_value":"93.6","min_value":"-2845.0",
"tags":["Temp 1"],
"unit":{"symbol":"F","label":"Degrees"}
}],
"location":{
"disposition":"fixed",
"exposure":"outdoor",
"domain":"physical"
}
}
But In only want the current_value 76.20. Is there a way to add a filter or something to the URL so it only returns the current value?
I am presuming that you are not intending to use a JSON parser, as otherwise it wouldn't be a problem to get what you need as it's just
parsed_json['datastreams'][0]['current_value']
.With Xively API V2 you can use CSV format, it's more close to what you want.
retrieve a feed with datastream filter as you just showed, but using CSV:
GET https://api.xively.com/v2/feeds/65673.csv?datastreams=3
3,2013-08-05T09:18:01.566388Z,59.10
retrieve a datastream itself:
GET https://api.xively.com/v2/feeds/65673/datastreams/3.csv
2013-08-05T09:18:01.566388Z,59.10
The first example only makes sense when you are to fetch more then one datastream in a single request, but you don't want all of them so you would call:
GET https://api.xively.com/v2/feeds/65673.csv?datastreams=1,2,3
If all you want is just one datastream, you should use the second example and split on comma.