Validate an API key
curl --request POST \
--url https://integration.smartpng.com/api/validate \
--header 'Content-Type: application/json' \
--data '
{
"api_key": "sp_live_abc123def456ghi789"
}
'import requests
url = "https://integration.smartpng.com/api/validate"
payload = { "api_key": "sp_live_abc123def456ghi789" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({api_key: 'sp_live_abc123def456ghi789'})
};
fetch('https://integration.smartpng.com/api/validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://integration.smartpng.com/api/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'api_key' => 'sp_live_abc123def456ghi789'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://integration.smartpng.com/api/validate")
.header("Content-Type", "application/json")
.body("{\n \"api_key\": \"sp_live_abc123def456ghi789\"\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://integration.smartpng.com/api/validate");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n \"api_key\": \"sp_live_abc123def456ghi789\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"valid": true,
"user_id": "2ef2a1c4-0b73-4fd8-b065-418f79b4fd7c",
"subscription_type": "Paid",
"credits_remaining": 500,
"max_image_size": 10485760
}Endpoints
POST /validate
Validate an API key and return the current credit balance.
POST
https://integration.smartpng.com/api
/
validate
Validate an API key
curl --request POST \
--url https://integration.smartpng.com/api/validate \
--header 'Content-Type: application/json' \
--data '
{
"api_key": "sp_live_abc123def456ghi789"
}
'import requests
url = "https://integration.smartpng.com/api/validate"
payload = { "api_key": "sp_live_abc123def456ghi789" }
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({api_key: 'sp_live_abc123def456ghi789'})
};
fetch('https://integration.smartpng.com/api/validate', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://integration.smartpng.com/api/validate",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'api_key' => 'sp_live_abc123def456ghi789'
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}HttpResponse<String> response = Unirest.post("https://integration.smartpng.com/api/validate")
.header("Content-Type", "application/json")
.body("{\n \"api_key\": \"sp_live_abc123def456ghi789\"\n}")
.asString();using RestSharp;
var options = new RestClientOptions("https://integration.smartpng.com/api/validate");
var client = new RestClient(options);
var request = new RestRequest("");
request.AddJsonBody("{\n \"api_key\": \"sp_live_abc123def456ghi789\"\n}", false);
var response = await client.PostAsync(request);
Console.WriteLine("{0}", response.Content);
{
"valid": true,
"user_id": "2ef2a1c4-0b73-4fd8-b065-418f79b4fd7c",
"subscription_type": "Paid",
"credits_remaining": 500,
"max_image_size": 10485760
}Overview
Use this endpoint as a lightweight preflight check before sending compression requests.Notes
- The request body is JSON.
- The endpoint returns whether the key is valid, the current balance, and the maximum allowed file size.
- This endpoint does not consume credits.
Body
application/json
SmartPNG API key
Example:
"sp_live_abc123def456ghi789"
Response
API key is valid
Example:
true
SmartPNG user identifier
Example:
"2ef2a1c4-0b73-4fd8-b065-418f79b4fd7c"
Available options:
Free, Paid Example:
"Paid"
Remaining free and paid credits
Example:
500
Maximum upload size in bytes
Example:
10485760
