Verificação básica de saúde
GET /health
Se a API está no ar. Não precisa de chave de API.
Autenticação
Pública: não precisa de chave de API.
Respostas
200 OK
API está saudável
Campos da resposta
statustimestampuptimeenvironmentloadTestMode
503 Service Unavailable
API está com problemas
bash
#!/usr/bin/env bash
# Whether the API is up: "status": "ok" when it is.
# A public endpoint: no key needed.
set -euo pipefail
curl -sS --max-time 30 https://api.docsocr.com/api/v1/healthpython
"""Whether the API is up: "status": "ok" when it is.
A public endpoint: no key needed. Needs the requests package.
"""
import requests
response = requests.get("https://api.docsocr.com/api/v1/health", timeout=30)
response.raise_for_status()
print(response.json()["status"])js
// Whether the API is up: "status": "ok" when it is.
// A public endpoint: no key needed. Needs Node.js 18+.
const response = await fetch('https://api.docsocr.com/api/v1/health', {
signal: AbortSignal.timeout(30_000),
})
if (!response.ok) {
console.error(response.status)
process.exit(1)
}
console.log((await response.json()).status)php
<?php
// Whether the API is up: "status": "ok" when it is.
// A public endpoint: no key needed. Needs the curl extension.
$request = curl_init('https://api.docsocr.com/api/v1/health');
curl_setopt_array($request, [CURLOPT_RETURNTRANSFER => true, CURLOPT_TIMEOUT => 30]);
$body = curl_exec($request);
if ($body === false || curl_getinfo($request, CURLINFO_RESPONSE_CODE) !== 200) {
fwrite(STDERR, 'The API is not up' . PHP_EOL);
exit(1);
}
echo json_decode($body, true)['status'], PHP_EOL;java
// Whether the API is up: "status": "ok" when it is.
// A public endpoint: no key needed. Needs Java 17+. Run: java Health.java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.time.Duration;
public class Health {
public static void main(String[] args) throws Exception {
HttpRequest request = HttpRequest.newBuilder(URI.create("https://api.docsocr.com/api/v1/health"))
.timeout(Duration.ofSeconds(30))
.GET()
.build();
HttpResponse<String> response = HttpClient.newHttpClient().send(request, HttpResponse.BodyHandlers.ofString());
// The answer is JSON, e.g. {"status": "ok", ...}; read it with your JSON library
System.out.println(response.body());
if (response.statusCode() != 200) {
System.exit(1);
}
}
}csharp
// Whether the API is up: "status": "ok" when it is.
// A public endpoint: no key needed. Needs .NET 8+. Run: dotnet run Health.cs (.NET 10)
using System.Text.Json;
using var http = new HttpClient { Timeout = TimeSpan.FromSeconds(30) };
using var response = await http.GetAsync("https://api.docsocr.com/api/v1/health");
if (!response.IsSuccessStatusCode)
{
Console.Error.WriteLine((int)response.StatusCode);
return 1;
}
using var health = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
Console.WriteLine(health.RootElement.GetProperty("status").GetString());
return 0;Testar
Envia esta requisição para a API em produção.
Esta chamada não custa créditos.