Ingesting DS API
Ingesting the Data Sutram API#
Below are a set of POST and GET requests done using a list of Programming Languages to help guide users how the Data Sutram API can be ingested.
GET Requests#
- cURL
- Javascript
- Java
- NodeJs
- PHP
- Python
curl --location --request GET 'https://console.datasutram.com/api/security/risk-assessment?ip=142.250.193.46' \
--header 'token: your-auth-token'
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("GET", "https://console.datasutram.com/api/security/risk-assessment?ip=142.250.193.46");
xhr.setRequestHeader("token", "your-auth-token");
xhr.send();
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
Request request = new Request.Builder()
.url("https://console.datasutram.com/api/security/risk-assessment?ip=142.250.193.46")
.method("GET", null)
.addHeader("token", "your-auth-token")
.build();
Response response = client.newCall(request).execute();
var request = require('request');
var options = {
'method': 'GET',
'url': 'https://console.datasutram.com/api/security/risk-assessment?ip=142.250.193.46',
'headers': {
'token': 'your-auth-token'
}
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://console.datasutram.com/api/security/risk-assessment?ip=142.250.193.46',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'GET',
CURLOPT_HTTPHEADER => array(
'token: your-auth-token'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
url = "https://console.datasutram.com/api/security/risk-assessment?ip=142.250.193.46"
payload={}
headers = {
'token': 'your-auth-token'
}
response = requests.request("GET", url, headers=headers, data=payload)
print(response.text)
POST Requests#
- cURL
- Javascript
- Java
- NodeJs
- PHP
- Python
curl --location --request POST 'https://console.datasutram.com/api/scorecard/merchant-v3' \
--header 'token: your-auth-token' \
--header 'Content-Type: application/json' \
--data-raw '{
"address": "Multiplex Theatre, Bandra West, Mumbai",
"radius": 1
}'
var data = JSON.stringify({
"address": "Multiplex Theatre, Bandra West, Mumbai",
"radius": 1
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function() {
if(this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://console.datasutram.com/api/scorecard/merchant-v3");
xhr.setRequestHeader("token", "your-auth-token");
xhr.setRequestHeader("Content-Type", "application/json");
xhr.send(data);
OkHttpClient client = new OkHttpClient().newBuilder()
.build();
MediaType mediaType = MediaType.parse("application/json");
RequestBody body = RequestBody.create(mediaType, "{\n \"address\": \"Multiplex Theatre, Bandra West, Mumbai\",\n \"radius\": 1\n}");
Request request = new Request.Builder()
.url("https://console.datasutram.com/api/scorecard/merchant-v3")
.method("POST", body)
.addHeader("token", "your-auth-token")
.addHeader("Content-Type", "application/json")
.build();
Response response = client.newCall(request).execute();
var request = require('request');
var options = {
'method': 'POST',
'url': 'https://console.datasutram.com/api/scorecard/merchant-v3',
'headers': {
'token': 'your-auth-token',
'Content-Type': 'application/json'
},
body: JSON.stringify({
"address": "Multiplex Theatre, Bandra West, Mumbai",
"radius": 1
})
};
request(options, function (error, response) {
if (error) throw new Error(error);
console.log(response.body);
});
<?php
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => 'https://console.datasutram.com/api/scorecard/merchant-v3',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => '',
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 0,
CURLOPT_FOLLOWLOCATION => true,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS =>'{
"address": "Multiplex Theatre, Bandra West, Mumbai",
"radius": 1
}',
CURLOPT_HTTPHEADER => array(
'token: your-auth-token',
'Content-Type: application/json'
),
));
$response = curl_exec($curl);
curl_close($curl);
echo $response;
import requests
import json
url = "https://console.datasutram.com/api/scorecard/merchant-v3"
payload = json.dumps({
"address": "Multiplex Theatre, Bandra West, Mumbai",
"radius": 1
})
headers = {
'token': 'your-auth-token',
'Content-Type': 'application/json'
}
response = requests.request("POST", url, headers=headers, data=payload)
print(response.text)