我对西弗利是新手。现在,我正在尝试从我获得的提要访问数据点历史记录。从文档中可以看到:http://xively.github.io/xively-js/docs/我似乎可以使用xively.datapoint.history(feedID,datastreamID,options{},callback(data))方法,但我不知道如何使用它。
我知道参数feedID,datastreamID,但是我不确定这些选项...从https://xively.com/dev/docs/api/quick_reference/historical_data/站点开始,我想我应该放入开始和结束参数。我使用了feed id:40053和datastream id:airpressure。您可以尝试在此处输入提要id以获取有关它的更多信息:http://xively.github.io/xively-js/demo/
我尝试了下面的代码,但它不工作。是我做错了什么,还是数据点历史本身受到限制,无法访问?
// Make sure the document is ready to be handled
$(document).ready(function($) {
// Set the Xively API key (https://xively.com/users/YOUR_USERNAME/keys)
xively.setKey("yWYxyi3HpdqFCBtKHueTvOGoGROSAKxGRFAyQWk5d3JNdz0g" );
// Replace with your own values
var feedID = 40053;
var datastreamID = "airpressure"; // Datastream ID
// Get datastream data from Xively
xively.datapoint.history(feedID, datastreamID,
{
start:"2013-09-10T00:00:00.703576Z",
end:"2013-10-10T00:00:00.703576Z"
},
function(data){
//data.forEach(function(datapoints){document.write(JSON.stringify(datapoints["value"], null, 4));});
document.write(JSON.stringify(data, null, 4));
});
});发布于 2013-10-28 19:32:12
我没有正确阅读文档...每次查询的最大持续时间是6小时,因此将结束时间更改为"2013-09-10T06:00:00.703576Z解决了我的问题。
发布于 2016-02-18 01:43:17
您可以使用参数:duration、interval
xively.datapoint.history (feedID, datastreamID1, **{ duration: "14days", interval: "1000"}**,
function(data){
document.write(JSON.stringify(data, null, 4));
}
);发布于 2013-11-02 02:48:48
阿尔维纳迪,没错。您可以做的另一件事是将interval参数设置为大于0的值。这将降低数据点的密度,并且对于间隔中指定的每隔几秒只返回一个数据点。但是,在尝试检索大量数据的平均值时,这可能很有用。
下面是解释可用间隔的API文档:https://xively.com/dev/docs/api/quick_reference/historical_data/
Pro提示:设置参数limit=1000以返回最大数量的结果,而不必对数据进行分页。
https://stackoverflow.com/questions/19570283
复制相似问题