1
2
3
Getting Started use API
Sign up for an account.
File scan settings
Access the dashboard to configure your API settings for efficient file scanning.
Get your API KEY in your dashboard
Log in to your dashboard to obtain your unique API key, essential for authenticating requests and securely accessing all API functionalities. The API key is your gateway to integrating the scanning services seamlessly into your applications.
4
Make a call for file scanning.
POSTAPI key required
https://api.nudescan.io/v1/scan/image
curl -X POST https://api.nudescan.io/v1/scan/image \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Transfer-Encoding: chunked" \
-F "files=@/path/to/photo1.jpg;type=application/octet-stream" \
-F "files=@/path/to/photo2.jpg;type=application/octet-stream"
const axios = require('axios');
const fs = require('fs');
const FormData = require('form-data');
// Define the API endpoint
const apiUrl = 'https://api.nudescan.io/v1/scan/image';
// Define the function to make the POST request
async function sendPostRequest(photoFiles) {
try {
const form = new FormData();
// Add all files as "files"
photoFiles.forEach((photo) => {
form.append('files', fs.createReadStream(photo.path), {
filename: photo.filename,
contentType: 'application/octet-stream', // Specify the content type
Authorization: 'Bearer YOUR_API_KEY' // Add the API key as a Bearer token
});
});
const response = await axios.post(apiUrl, form, {
headers: {
...form.getHeaders()
}
});
const { results } = response.data;
// Update the photoFiles with the 'abuse' value
return photoFiles.map((photo, index) => {
return { ...photo, abuse: results[index] };
});
} catch (error) {
console.error('Error sending photos for classification:', error.message);
throw error;
}
}
// Call the function
sendPostRequest();
<?php
// API URL
$apiUrl = 'https://api.nudescan.io/v1/scan/image';
$apiKey = 'YOUR_API_KEY';
// Funktion zum Senden des POST-Requests
function sendPostRequest(array $photoFiles) {
global $apiUrl, $apiKey;
$curl = curl_init();
$boundary = uniqid();
$delimiter = '-------------' . $boundary;
$eol = "\r\n";
$headers = [
"Authorization: Bearer $apiKey",
"Content-Type: multipart/form-data; boundary=" . $delimiter
];
$body = '';
foreach ($photoFiles as $index => $photo) {
$filePath = $photo['path'];
$filename = $photo['filename'];
if (file_exists($filePath)) {
$fileContents = file_get_contents($filePath);
$body .= "--" . $delimiter . $eol;
$body .= 'Content-Disposition: form-data; name="files[]"; filename="' . $filename . '"' . $eol;
$body .= 'Content-Type: application/octet-stream' . $eol . $eol;
$body .= $fileContents . $eol;
}
}
$body .= "--" . $delimiter . "--" . $eol;
curl_setopt_array($curl, [
CURLOPT_URL => $apiUrl,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => $body
]);
$response = curl_exec($curl);
$httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
if ($httpCode !== 200) {
echo "Error sending photos for classification: " . curl_error($curl) . PHP_EOL;
curl_close($curl);
return false;
}
curl_close($curl);
$responseData = json_decode($response, true);
if (isset($responseData['results'])) {
foreach ($photoFiles as $index => &$photo) {
$photo['abuse'] = $responseData['results'][$index] ?? null;
}
}
return $photoFiles;
}
// Beispielaufruf
$photos = [
['path' => 'path/to/photo1.jpg', 'filename' => 'photo1.jpg'],
['path' => 'path/to/photo2.jpg', 'filename' => 'photo2.jpg']
];
$result = sendPostRequest($photos);
print_r($result);
import requests
# API URL
api_url = "https://api.nudescan.io/v1/scan/image"
api_key = "YOUR_API_KEY"
def send_post_request(photo_files):
headers = {
"Authorization": f"Bearer {api_key}"
}
files = [
('files', (photo['filename'], open(photo['path'], 'rb'), 'application/octet-stream'))
for photo in photo_files
]
try:
response = requests.post(api_url, headers=headers, files=files)
response.raise_for_status()
response_data = response.json()
# Update photo_files with 'abuse' values
if 'results' in response_data:
for index, photo in enumerate(photo_files):
photo['abuse'] = response_data['results'][index] if index < len(response_data['results']) else None
return photo_files
except requests.RequestException as e:
print(f"Error sending photos for classification: {e}")
raise
# Beispielaufruf
photos = [
{'path': 'path/to/photo1.jpg', 'filename': 'photo1.jpg'},
{'path': 'path/to/photo2.jpg', 'filename': 'photo2.jpg'}
]
result = send_post_request(photos)
print(result)
Next
Authentication
