[SOLVED] Why am I only able to get 50 data points at a time?

I am using the block of text below to pull data points from a variable between two dates. All this works perfectly until my request requires more than 50 data points. Is there some setting to allow more datapoints to be downloaded at once?

Code snippet (JavaScript / jQuery):
// Get details of each variable
function getDetails(url) {
$.ajax({
url: url,
data: { “token”: user_token, “start”: start_date, “end”: end_date }
}).done(function (data) {
data.results.forEach(function (data) {
dataCounts.unshift(data.value); // Since we get the values last in / first out
dataTimes.unshift(new Date(data.created_at));
});

Hey @chipmc you can use the pagination feature, for example:

things.ubidots.com/api/v1.6/variables/{variable_id}/values/?page_size=1000&token=XXXXXXXX

That does sounds like the right command but, I am not sure how to implement it. Here is what I am doing:

// Request trail count data from Ubidots - looking for People
function getVariables(url) {
$.ajax({
url: url,
data: { “token”: user_token }
}).done(function (data) {
var variables = data.results;
variables.forEach(function (variable) {
if (variable.name == “People”) {
setPagination(variable.values_url);
getDetails(variable.values_url);
}
});
});
}

// Set the pagination to 1000
function setPagination(url) {
var paginationUrl = url + “/?page_size=1000”;
console.log(paginationUrl);
$.ajax({
url: paginationUrl,
data: { “token”: user_token}
}).done();
}

From the console log:
http://things.ubidots.com/api/v1.6/variables/543754a67625423611d25340/values/?page_size=1000

Thanks for your help

Chip

Hi, @chipmc you can use the data parameter:

function getVariables(url) {
    $.ajax({
        url: url,
        data: { "token": user_token,
                    "page_size": 1000} 
        }).done(function (data) {
        var variables = data.results;
        variables.forEach(function (variable) {
...
...

Woakas, To the rescue again. I added this to the getVariables function and was able to get all the datapoints I needed. Someday, when I am not so busy trying to get something to work, I need to study that whole CURL to Ajax thing. Thanks again!

We thought it was useful to highlight that we have a new JQuery library, kindly developed by a community member.

Hello i am using java, the same problem, how can i work with more than 50 datapoints ???