Get data of a Datasource
Endpoint Name: getdatasourcebyname
Request type : POST
Authorization: Bearer token as header
Endpoint Details: The getdatasourcebynameendpoint
will be used to get data of datasource.
Method
URL
POST
URL/access/klearstack/getdatasourcebyname
Request Body
Params
Values
Description
company_name
string
Name of the company for which the user is logging in
datasource_name
string
Name of the datasource
page_index
string
Page number of Paginated data
items_per_page
string
Number or records per page is required (Max : 100)
Shell (cURL)
Request Body
curl -X POST "URL/access/klearstack/getdatasourcebyname" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your_token_here" \
-d '{
"company_name": "Replace_Company_Name_Here",
"datasource_name": "Replace_Datasource_Name_Here",
"page_index": "Replace_Page_Index_Here",
"items_per_page": "Replace_Items_Per_Page_Here"
}'
Python
Request Body
import requests
# API URL
url = "URL/access/klearstack/getdatasourcebyname"
# Request payload
data = {
"company_name": "Replace_Company_Name_Here",
"datasource_name": "Replace_Datasource_Name_Here",
"page_index": "Replace_Page_Index_Here",
"items_per_page": "Replace_Items_Per_Page_Here"
}
# Headers
headers = {
"Content-Type": "application/json",
"Authorization": "Bearer your_token_here"
}
# Make the POST request
response = requests.post(url, json=data, headers=headers)
# Print the response
if response.status_code == 200:
print(response.json())
else:
print("Error:", response.text)
Java
Request Body
import okhttp3.*;
import java.io.IOException;
public class GetDatasourceByNameAPI {
public static void main(String[] args) {
OkHttpClient client = new OkHttpClient();
// JSON payload
String jsonPayload = "{ \"company_name\": \"Replace_Company_Name_Here\", " +
"\"datasource_name\": \"Replace_Datasource_Name_Here\", " +
"\"page_index\": \"Replace_Page_Index_Here\", " +
"\"items_per_page\": \"Replace_Items_Per_Page_Here\" }";
RequestBody body = RequestBody.create(
jsonPayload, MediaType.parse("application/json"));
Request request = new Request.Builder()
.url("URL/access/klearstack/getdatasourcebyname")
.post(body)
.addHeader("Content-Type", "application/json")
.addHeader("Authorization", "Bearer your_token_here")
.build();
try (Response response = client.newCall(request).execute()) {
if (response.isSuccessful()) {
System.out.println("Response: " + response.body().string());
} else {
System.out.println("Error: " + response.body().string());
}
} catch (IOException e) {
e.printStackTrace();
}
}
}
Node.js
Request Body
var request = require('request');
const form_data = {
'company_name': 'Replace_Company_Name_Here',
'datasource_name': 'Replace_Datasource_Name_Here',
'page_index': 'Replace_Page_Index_Here',
'items_per_page': 'Replace_Items_Per_Page_Here'
};
const options = {
url: 'URL/access/klearstack/getdatasourcebyname',
formData: form_data,
headers: {
'Content-Type': 'application/x-www-form-urlencoded',
'Authorization': 'Bearer your_token_here'
}
};
request.post(options, function(err, httpResponse, body) {
if (err) {
console.error('Request failed:', err);
return;
}
console.log('Response:', body);
});
JavaScript (XMLHttpRequest)
Request Body
var payload = JSON.stringify({
company_name: "Replace_Company_Name_Here",
datasource_name: "Replace_Datasource_Name_Here",
page_index: "Replace_Page_Index_Here",
items_per_page: "Replace_Items_Per_Page_Here"
});
var xhr = new XMLHttpRequest();
xhr.open("POST", "URL/access/klearstack/getdatasourcebyname", true);
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Authorization", "Bearer your_token_here");
// Handle response
xhr.onreadystatechange = function () {
if (xhr.readyState === XMLHttpRequest.DONE) {
if (xhr.status === 200) {
console.log("Response:", xhr.responseText);
} else {
console.error("Error:", xhr.responseText);
}
}
};
xhr.send(payload);
API Response
Status code
Example Response
200
{
"DataSourceName": "vendor email",
"DataSourceType": "excel_or_csv",
"DataSourceStatus": "true",
"Total_fields": 596,
"Page_number": 1,
"fields": [
{
"name": "USER_FIRST_NAME",
"datatype": "string"
},
{
"name": "USER_LAST_NAME",
"datatype": "string"
},
{
"name": "email",
"datatype": "string"
},
],
"data": [
{
"_id": {
"$oid": "644ba49a6f4023afbca88c94"
},
"USER_FIRST_NAME": "Marti",
"USER_LAST_NAME": "URIB",
"email": "martin@colibriflowers.com"
},
{
"_id": {
"$oid": "644ba49a6f4023afbca88c95"
},
"USER_FIRST_NAME": "Ana Lucia",
"USER_LAST_NAME": "Andrade",
"email": "aandrade@equatoroses.com"
}
],
“release_version”:”7.8.9”
}
Last updated