Skip to content

Instantly share code, notes, and snippets.

@alasarr
Created March 14, 2017 17:31
Show Gist options
  • Save alasarr/c027051f7baa7ea05b7cf6b40349bac8 to your computer and use it in GitHub Desktop.
Save alasarr/c027051f7baa7ea05b7cf6b40349bac8 to your computer and use it in GitHub Desktop.
CARTO batch API sample script
var request = require("request");
var api_key = "XXXX";
var url = "https://{{account}}.carto.com/api/v2/sql/job";
var options = {
method: "POST",
url: url,
qs: {
"api_key": api_key
},
headers: {
"content-type": "application/json"
},
body: {
query: "select 'heavy query' "
},
json: true
};
request(options, function (error, response, body) {
if (error) throw new Error(error);
console.log(url+'/'+body.job_id+'?api_key='+api_key);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment