Image operations via REST API
An alternative to using the web platform for image management is using the SentiSight API. Currently, our API allows users to create projects, upload images, retrieve or delete uploaded images.
To use the REST API you will need these details:
- API token (available under "User profile" menu tab)
- Project ID (available under "User profile" menu tab)
- Image name
The API endpoint is: https://platform.sentisight.ai/api/image/ for image operations and https://platform.sentisight.ai/api/project/ for project operations.
The required parameters together with code samples are provided below.
This page does not cover making predictions via REST API, check out our other user guide pages for that.
Creating a project
Set the "X-Auth-token" header to your API token string and set "Content-Type" header to "application/json". Specify the following URL parameter: name (the name of the project you are creating). The URL should look like this: https://platform.sentisight.ai/api/project/(project name). Set the HTTP method to POST.
TOKEN="your_token"
NAME="your_project_name"
curl --location --request POST "https://platform.sentisight.ai/api/image/$NAME' \
--header "X-Auth-token: $TOKEN" \
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class App
{
public static void main( String[] args ) throws IOException
{
if (args.length < 2) {
System.out.println("Usage: java -jar sample.jar api_token name");
}
String token = args[0];
String name = args[1];
URL url = new-6.html URL("https://platform.sentisight.ai/api/project/" + name);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("X-Auth-token", token);
connection.setRequestMethod("POST");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String output;
while ((output = in.readLine()) != null) {
System.out.println(output);
}
in.close();
}
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Sample</title>
<script>
const baseApiURL = 'https://platform.sentisight.ai/api/';
let token = '';
let name;
function createProject() {
document.getElementById('button').disabled = true;
token = document.getElementById('token_field').value;
name = document.getElementById('name').value;
const xmlHttp = new XMLHttpRequest();
xmlHttp.open('POST', baseApiURL + 'project/' + name);
xmlHttp.setRequestHeader('Content-Type', ''application/');
xmlHttp.setRequestHeader('X-Auth-token', token);
xmlHttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
document.getElementById('button').disabled = false;
document.getElementById('output').innerHTML = xmlHttp.responseText;
}
}
xmlHttp.send();
}
</script>
</head>
<body>
Token: <input id="token_field" type="text">
<br>
Project name: <input id="name" type="text">
<br>
<button id="button" type="button" onclick="deleteImage()">Delete Image</button>
<br>
<p id="output"></p>
</body>
</html>
import requests
token = "your_token"
name = "your_project_name"
headers = {"X-Auth-token": token, "Content-Type": "application/json"}
with open(name, 'rb') as handle:
r = requests.post(
'https://platform.sentisight.ai/api/project/{}'.format(name),
headers=headers, data=handle)
if r.status_code == 200:
print(r.text)
else:
print('Error occured with REST API.')
print('Status code: {}'.format(r.status_code))
print('Error message: ' + r.text)
using System;
using System.Net.Http;
namespace Sample
{
class Program
{
static void Main()
{
const string token = "";
const string name= "";
var uri = new Uri($"https://platform.sentisight.ai/api/project/{name}");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Auth-token", token);
var response = client.PostAsync(uri);
var result = response.Result.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
}
Uploading images
Upload an image from your computer
Set the "X-Auth-token" header to your API token string and set "Content-Type" header to "application/octet-stream". Set the body to your image file. Specify the following URL parameters: project ID (ID of project you want to upload your image to), image name (how your image will be named in the project), preprocess ("true" if you want your image to be preprocessed, otherwise "false"). The URL should look like this: https://platform.sentisight.ai/api/image/(project ID)/(image name)?preprocess=("true" or "false"). Set the HTTP method to POST.
TOKEN="your_token"
PROJECT_ID="your_project_id"
IMAGE_PATH="your_image_path"
IMAGE_NAME="your_image_name"
PREPROCESS="true"
curl --location --request POST "https://platform.sentisight.ai/api/image/$PROJECT_ID/$IMAGE_NAME?preprocess=$PREPROCESS" \
--header "Content-Type: application/octet-stream" \
--header "X-Auth-token: $TOKEN" \
--data-binary @"$IMAGE_PATH"
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.File;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
public class App
{
public static void main( String[] args ) throws IOException
{
if (args.length < 5) {
System.out.println("Usage: java -jar sample.jar api_token project_id image_name preprocess file");
}
String token = args[0];
String projectId = args[1];
String imageName = args[2];
String preprocess = args[3];
String imageFilename = args[4];
byte[] bytes = Files.readAllBytes(new File(imageFilename).toPath());
URL url = new-6.html URL("https://platform.sentisight.ai/api/image/" + projectId + "/" + imageName
+ "?preprocess=" + preprocess);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Content-Type", "application/octet-stream");
connection.setRequestProperty("X-Auth-token", token);
connection.setRequestMethod("POST");
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.write(bytes);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String output;
while ((output = in.readLine()) != null) {
System.out.println(output);
}
in.close();
}
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Sample</title>
<script type="text/javascript">
const baseApiURL = 'https://platform.sentisight.ai/api/';
let token = '';
function uploadImage() {
token = document.getElementById('tokenfield').value;
const projectId = document.getElementById('project').value;
const imageName = document.getElementById('image_name').value;
const input = document.getElementById('upload');
const file = input.files[0];
const fr = new FileReader();
const preprocess = document.getElementById('preprocess-on').checked;
fr.onload = function() {
document.getElementById('output').innerHTML =
apiPostRequest('image/' + projectId + '/' + imageName + '?preprocess=' + preprocess, fr.result);
}
fr.readAsArrayBuffer(file);
}
function apiPostRequest(request, body) {
const xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", baseApiURL + request, false );
xmlHttp.setRequestHeader('Content-Type', 'application/octet-stream');
xmlHttp.setRequestHeader('X-Auth-token', token);
xmlHttp.send(body);
console.log(xmlHttp.responseText);
return xmlHttp.responseText;
}
</script>
</head>
<body>
Token: <input id="tokenfield" type="text" name="" value="">
<br>
Project id: <input id="project" type="number" name="" value="">
<br>
Image name: <input id="image_name" type="text" name="" value="">
<br>
<input id="preprocess-on" type="checkbox">Preprocess
<br>
Upload image: <input id="upload" type="file" name="" value="">
<br>
<button type="button" onclick="uploadImage()">Upload Image</button>
<br><br><br>
<p id="output">Your results will go here!</p>
</body>
</html>
import requests
token = "your_token"
project_id = "your_project_id"
image_name = "your_image_name"
image_filename = "your_image_path"
preprocess = "true"
headers = {"X-Auth-token": token, "Content-Type": "application/octet-stream"}
with open(image_filename, 'rb') as handle:
r = requests.post(
'https://platform.sentisight.ai/api/image/{}/{}?preprocess={}'.format(project_id, image_name, preprocess),
headers=headers, data=handle)
if r.status_code == 200:
print(r.text)
else:
print('Error occured with REST API.')
print('Status code: {}'.format(r.status_code))
print('Error message: ' + r.text)
using System;
using System.IO;
using System.Net.Http;
using System.Net.Http.Headers;
namespace Sample
{
class Program
{
static void Main()
{
const string token = "";
const int projectId = 0;
const string preprocess = "true";
const string imageName = "";
const string imageFilename = "";
var bytes = File.ReadAllBytes(imageFilename);
var data = new ByteArrayContent(bytes);
data.Headers.ContentType = MediaTypeHeaderValue.Parse("application/octet-stream");
var uri = new Uri($"https://platform.sentisight.ai/api/image/{projectId}/{imageName}?preprocess={preprocess}");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Auth-token", token);
var response = client.PostAsync(uri, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
}
Upload an image using a URL
Uploading an image by providing a URL is similar to the previous case of uploading an image from your computer. The only differences are that you need to set the "Content-Type" header to "application/json" and set the body to a JSON formatted string with a "url" parameter specifying the image URL.
TOKEN="your_token"
PROJECT_ID="your_project_id"
IMAGE_URL="your_image_url"
IMAGE_NAME="your_image_name"
PREPROCESS="true"
curl --location --request POST "https://platform.sentisight.ai/api/image/$PROJECT_ID/$IMAGE_NAME?preprocess=$PREPROCESS" \
--header "Content-Type: application/json" \
--header "X-Auth-token: $TOKEN" \
--data-raw '{
"url": "$IMAGE_URL"
}'
package sentisight.api.sample;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class App
{
public static void main( String[] args ) throws IOException
{
String token = "";
String projectId = "";
String imageName = "";
boolean preprocess = true;
String imageUrl = "";
String body = "{\r\n \"url\": \"%s\"\r\n}".formatted(imageUrl);
URL url = new URL("https://platform.sentisight.ai/api/image/" + projectId + "/" + imageName
+ "?preprocess=" + preprocess);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("X-Auth-token", token);
connection.setRequestMethod("POST");
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(body);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String output;
while ((output = in.readLine()) != null) {
System.out.println(output);
}
in.close();
}
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Sample</title>
<script type="text/javascript">
const baseApiURL = 'https://platform.sentisight.ai/api/';
let token = '';
function uploadImage() {
token = document.getElementById('tokenfield').value;
const projectId = document.getElementById('project').value;
const imageName = document.getElementById('image_name').value;
const preprocess = document.getElementById('preprocess-on').checked;
const url = document.getElementById('url').value;
const data = JSON.stringify({
url
});
document.getElementById('output').innerHTML =
apiPostRequest('image/' + projectId + '/' + imageName + '?preprocess=' + preprocess, data);
}
function apiPostRequest(request, body) {
const xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", baseApiURL + request, false );
xmlHttp.setRequestHeader('Content-Type', 'application/json');
xmlHttp.setRequestHeader('X-Auth-token', token);
xmlHttp.send(body);
console.log(xmlHttp.responseText);
return xmlHttp.responseText;
}
</script>
</head>
<body>
Token: <input id="tokenfield" type="text" name="" value="">
<br>
Project id: <input id="project" type="number" name="" value="">
<br>
Image name: <input id="image_name" type="text" name="" value="">
<br>
<input id="preprocess-on" type="checkbox">Preprocess
<br>
URL: <input id="url" type="text" name="" value="">
<br>
<button type="button" onclick="uploadImage()">Upload Image</button>
<br><br><br>
<p id="output">Your results will go here!</p>
</body>
</html>
import requests
import json
token = "your_token"
project_id = "your_project_id"
image_name = "your_image_name"
image_url = "http://your-image-url.png"
preprocess = "true"
payload = json.dumps({
"url": image_url
})
headers = {"X-Auth-token": token, "Content-Type": "application/json"}
r = requests.post(
'https://platform.sentisight.ai/api/image/{}/{}?preprocess={}'.format(project_id, image_name, preprocess),
headers=headers, data=payload)
if r.status_code == 200:
print(r.text)
else:
print('Error occured with REST API.')
print('Status code: {}'.format(r.status_code))
print('Error message: ' + r.text)
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
namespace Sample
{
class Program
{
static void Main()
{
const string token = "";
const int projectId = 0;
const string preprocess = "true";
const string imageName = "";
const string imageUrl = "";
using var ms = new MemoryStream();
using var writer = new Utf8JsonWriter(ms);
writer.WriteStartObject();
writer.WriteString("url", imageUrl);
writer.WriteEndObject();
writer.Flush();
var json = Encoding.UTF8.GetString(ms.ToArray());
var data = new StringContent(json, Encoding.Default, "application/json");
var uri = new Uri($"https://platform.sentisight.ai/api/image/{projectId}/{imageName}?preprocess={preprocess}");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Auth-token", token);
var response = client.PostAsync(uri, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
}
Upload a Base64 encoded image
Using the REST API by providing a Base64 encoded image is very similar to the case of using REST API with an image URL. The only difference is that you need to change the JSON parameter name "url" to "base64".
TOKEN="your_token"
PROJECT_ID="your_project_id"
IMAGE_B64=""
IMAGE_NAME="your_image_name"
PREPROCESS="true"
curl --location --request POST "https://platform.sentisight.ai/api/image/$PROJECT_ID/$IMAGE_NAME?preprocess=$PREPROCESS" \
--header "Content-Type: application/json" \
--header "X-Auth-token: $TOKEN" \
--data-raw '{
"base64": "$IMAGE_B64"
}'
package sentisight.api.sample;
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class App
{
public static void main( String[] args ) throws IOException
{
String token = "";
String projectId = "";
String imageName = "";
boolean preprocess = true;
String image_b64 = "";
String body = "{\r\n \"base64\": \"%s\"\r\n}".formatted(image_b64);
URL url = new URL("https://platform.sentisight.ai/api/image/" + projectId + "/" + imageName
+ "?preprocess=" + preprocess);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("X-Auth-token", token);
connection.setRequestMethod("POST");
connection.setDoOutput(true);
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
wr.writeBytes(body);
wr.flush();
wr.close();
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String output;
while ((output = in.readLine()) != null) {
System.out.println(output);
}
in.close();
}
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Sample</title>
<script type="text/javascript">
const baseApiURL = 'https://platform.sentisight.ai/api/';
let token = '';
function uploadImage() {
token = document.getElementById('tokenfield').value;
const projectId = document.getElementById('project').value;
const imageName = document.getElementById('image_name').value;
const preprocess = document.getElementById('preprocess-on').checked;
const base64 = document.getElementById('base64').value;
const data = JSON.stringify({
base64
});
document.getElementById('output').innerHTML =
apiPostRequest('image/' + projectId + '/' + imageName + '?preprocess=' + preprocess, data);
}
function apiPostRequest(request, body) {
const xmlHttp = new XMLHttpRequest();
xmlHttp.open( "POST", baseApiURL + request, false );
xmlHttp.setRequestHeader('Content-Type', 'application/json');
xmlHttp.setRequestHeader('X-Auth-token', token);
xmlHttp.send(body);
console.log(xmlHttp.responseText);
return xmlHttp.responseText;
}
</script>
</head>
<body>
Token: <input id="tokenfield" type="text" name="" value="">
<br>
Project id: <input id="project" type="number" name="" value="">
<br>
Image name: <input id="image_name" type="text" name="" value="">
<br>
<input id="preprocess-on" type="checkbox">Preprocess
<br>
Base64: <input id="base64" type="text" name="" value="">
<br>
<button type="button" onclick="uploadImage()">Upload Image</button>
<br><br><br>
<p id="output">Your results will go here!</p>
</body>
</html>
import requests
import json
token = "your_token"
project_id = "your_project_id"
image_name = "your_image_name"
image_b64 = ""
preprocess = "true"
payload = json.dumps({
"base64": image_b64
})
headers = {"X-Auth-token": token, "Content-Type": "application/json"}
r = requests.post(
'https://platform.sentisight.ai/api/image/{}/{}?preprocess={}'.format(project_id, image_name, preprocess),
headers=headers, data=payload)
if r.status_code == 200:
print(r.text)
else:
print('Error occured with REST API.')
print('Status code: {}'.format(r.status_code))
print('Error message: ' + r.text)
using System;
using System.IO;
using System.Net.Http;
using System.Text;
using System.Text.Json;
namespace Sample
{
class Program
{
static void Main()
{
const string token = "";
const int projectId = 0;
const string preprocess = "true";
const string imageName = "";
const string imageB64 = "";
using var ms = new MemoryStream();
using var writer = new Utf8JsonWriter(ms);
writer.WriteStartObject();
writer.WriteString("base64", imageB64);
writer.WriteEndObject();
writer.Flush();
var json = Encoding.UTF8.GetString(ms.ToArray());
var data = new StringContent(json, Encoding.Default, "application/json");
var uri = new Uri($"https://platform.sentisight.ai/api/image/{projectId}/{imageName}?preprocess={preprocess}");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Auth-token", token);
var response = client.PostAsync(uri, data);
var result = response.Result.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
}
Retrieving images
Set the "X-Auth-token" header to your API token string, specify your project ID and image name in the URL parameters. The URL should look like this: https://platform.sentisight.ai/api/image/(project ID)/(image name). Set the HTTP method to GET. Don't forget to change the "Content-Type" header to "text/plain" if you are modifying a request that you used to upload the image.
Image retrieval examples:
TOKEN="your_token"
PROJECT_ID="your_project_id"
IMAGE_NAME="your_image_name"
curl --location --request GET 'https://platform.sentisight.ai/api/image/$PROJECT_ID/$IMAGE_NAME' \
--header 'X-Auth-token: $TOKEN'
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
public class App {
public static void main( String[] args ) throws IOException
{
if (args.length < 3) {
System.out.println("Usage: java -jar sample.jar api_token project_id image_name");
}
String token = args[0];
String projectId = args[1];
String image_name = args[2];
URL url = new-6.html URL("https://platform.sentisight.ai/api/image/" + projectId + "/" + image_name);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Content-Type", "text/plain");
connection.setRequestProperty("X-Auth-token", token);
connection.setRequestMethod("GET");
FileOutputStream fileOutput = new FileOutputStream(image_name);
InputStream inputStream = connection.getInputStream();
byte[] buffer = new byte[1024];
int bufferLength;
while ( (bufferLength = inputStream.read(buffer)) > 0 ) {
fileOutput.write(buffer, 0, bufferLength);
}
inputStream.close();
fileOutput.close();
}
}
<!DOCTYPE htm>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Sample</title>
<script>
const baseApiURL = 'https://platform.sentisight.ai/api/';
let token = '';
let imageName;
let projectId;
function getImage() {
document.getElementById('button').disabled = true;
token = document.getElementById('token_field').value;
projectId = document.getElementById('project').value;
imageName = document.getElementById('image_name').value;
const xmlHttp = new XMLHttpRequest();
xmlHttp.open('GET', baseApiURL + 'image/' + projectId + '/' + imageName, true);
xmlHttp.setRequestHeader('Content-Type', 'text/plain');
xmlHttp.setRequestHeader('X-Auth-token', token);
xmlHttp.responseType = 'blob'
xmlHttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
document.getElementById('button').disabled = false;
document.getElementById('result').src = window.URL.createObjectURL(xmlHttp.response);
}
}
xmlHttp.send();
}
</script>
</head>
<body>
Token: <input id="token_field" type="text">
<br>
Project id: <input id="project" type="number">
<br>
Image name: <input id="image_name" type="text">
<br>
<button id="button" type="button" onclick="getImage()">Get Image</button>
<br>
<img src="" id="result">
</body>
</html>
import requests
import io
from PIL import Image
token = "your_token"
project_id = "your_project_id"
image_name = "your_image_name"
headers = {"X-Auth-token": token}
r = requests.get('https://platform.sentisight.ai/api/image/{}/{}/'.format(project_id, image_name),
headers=headers, data={})
if r.status_code == 200:
in_memory_file = io.BytesIO(r.content)
im = Image.open(in_memory_file)
im.show()
else:
print('Error occured with REST API.')
print('Status code: {}'.format(r.status_code))
print('Error message: ' + r.text)
using System;
using System.IO;
using System.Net.Http;
namespace Sample
{
class Program
{
static void Main()
{
const string token = "";
const int projectId = 0;
const string imageName = "";
var uri = new Uri($"https://platform.sentisight.ai/api/image/{projectId}/{imageName}");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Auth-token", token);
var response = client.GetByteArrayAsync(uri);
var imageBytes = response.Result;
var documentsPath = Environment.GetFolderPath(Environment.SpecialFolder.Personal);
var localPath = Path.Combine(documentsPath, imageName);
Console.WriteLine($"Image saved at: {localPath}");
File.WriteAllBytes(localPath, imageBytes);
}
}
}
Deleting images
Set the "X-Auth-token" header to your API token string, specify your project ID and image name in the URL parameters. The URL should look like this: https://platform.sentisight.ai/api/image/(project ID)/(image name). Set the HTTP method to DELETE. Don't forget to change the "Content-Type" header to "text/plain" if you are modifying a request that you used to upload the image.
Image deletion examples:
TOKEN="your_token"
PROJECT_ID="your_project_id"
IMAGE_NAME="your_image_name"
curl --location --request DELETE 'https://platform.sentisight.ai/api/image/$PROJECT_ID/$IMAGE_NAME' \
--header 'X-Auth-token: $TOKEN'
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
public class App
{
public static void main( String[] args ) throws IOException
{
if (args.length < 3) {
System.out.println("Usage: java -jar sample.jar api_token project_id image_name");
}
String token = args[0];
String projectId = args[1];
String image_name = args[2];
URL url = new-6.html URL("https://platform.sentisight.ai/api/image/" + projectId + "/" + image_name);
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
connection.setRequestProperty("Content-Type", "text/plain");
connection.setRequestProperty("X-Auth-token", token);
connection.setRequestMethod("DELETE");
BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));
String output;
while ((output = in.readLine()) != null) {
System.out.println(output);
}
in.close();
}
}
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>Sample</title>
<script>
const baseApiURL = 'https://platform.sentisight.ai/api/';
let token = '';
let imageName;
let projectId;
function deleteImage() {
document.getElementById('button').disabled = true;
token = document.getElementById('token_field').value;
projectId = document.getElementById('project').value;
imageName = document.getElementById('image_name').value;
const xmlHttp = new XMLHttpRequest();
xmlHttp.open('DELETE', baseApiURL + 'image/' + projectId + '/' + imageName, true);
xmlHttp.setRequestHeader('Content-Type', 'text/plain');
xmlHttp.setRequestHeader('X-Auth-token', token);
xmlHttp.onreadystatechange = function () {
if (this.readyState === 4 && this.status === 200) {
document.getElementById('button').disabled = false;
document.getElementById('output').innerHTML = xmlHttp.responseText;
}
}
xmlHttp.send();
}
</script>
</head>
<body>
Token: <input id="token_field" type="text">
<br>
Project id: <input id="project" type="number">
<br>
Image name: <input id="image_name" type="text">
<br>
<button id="button" type="button" onclick="deleteImage()">Delete Image</button>
<br>
<p id="output"></p>
</body>
</html>
import requests
token = "your_token"
project_id = "your_project_id"
image_name = "your_image_name"
headers = {"X-Auth-token": token}
r = requests.delete('https://platform.sentisight.ai/api/image/{}/{}/'.format(project_id, image_name),
headers=headers, data={})
if r.status_code == 200:
print(r.text)
else:
print('Error occured with REST API.')
print('Status code: {}'.format(r.status_code))
print('Error message: ' + r.text)
using System;
using System.Net.Http;
namespace Sample
{
class Program
{
static void Main()
{
const string token = "";
const int projectId = 0;
const string imageName = "";
var uri = new Uri($"https://platform.sentisight.ai/api/image/{projectId}/{imageName}");
var client = new HttpClient();
client.DefaultRequestHeaders.Add("X-Auth-token", token);
var response = client.DeleteAsync(uri);
var result = response.Result.Content.ReadAsStringAsync().Result;
Console.WriteLine(result);
}
}
}
SentiSight.ai OpenAPI specification
List of endpoints: https://app.swaggerhub.com/apis-docs/SentiSight.ai/sentisight.
API code samples: https://app.swaggerhub.com/apis/SentiSight.ai/sentisight.
You can try out our REST API interactively and convert Swagger specification to code samples in many different languages.