Integracao via API REST
Integre diretamente com a API REST do Sherlocker usando qualquer linguagem ou ferramenta HTTP. Nenhuma biblioteca adicional e necessaria.
Base URL
https://221b-api.sherlocker.com.br/api/v1
Autenticacao
Passe seu token via query parameter token em todas as requisicoes:
GET /pessoas/cpf/12345678900?token=SEU_TOKEN
Nunca exponha seu token em repositorios publicos ou codigo client-side. Use variaveis de ambiente no servidor.
Primeira requisicao
cURL
curl "https://221b-api.sherlocker.com.br/api/v1/pessoas/cpf/12345678900?token=SEU_TOKEN"
Python
import requests
BASE_URL = "https://221b-api.sherlocker.com.br/api/v1"
TOKEN = "SEU_TOKEN"
response = requests.get(
f"{BASE_URL}/pessoas/cpf/12345678900",
params={"token": TOKEN}
)
data = response.json()
print(data["name"])
Node.js
const BASE_URL = "https://221b-api.sherlocker.com.br/api/v1";
const TOKEN = "SEU_TOKEN";
const response = await fetch(
`${BASE_URL}/pessoas/cpf/12345678900?token=${TOKEN}`
);
const data = await response.json();
console.log(data.name);
PHP
$baseUrl = "https://221b-api.sherlocker.com.br/api/v1";
$token = "SEU_TOKEN";
$response = file_get_contents(
"{$baseUrl}/pessoas/cpf/12345678900?token={$token}"
);
$data = json_decode($response, true);
echo $data['name'];
Padrao de resposta
Todas as respostas seguem o mesmo formato JSON:
{
"success": true,
"status": "completed",
"results": [
{
"name": "Joao da Silva",
"cpf": "12345678900",
"birth_date": "1990-01-15"
}
]
}
| Campo | Tipo | Descricao |
|---|
success | boolean | Se a requisicao foi processada com sucesso |
status | string | completed, processing ou error |
results | array | Array com os resultados da consulta |
error | string | Mensagem de erro (quando success: false) |
Erros
| Status HTTP | Descricao | Acao |
|---|
401 | Token ausente ou invalido | Verifique seu token |
402 | Tokens insuficientes | Recarregue seu saldo |
404 | Recurso nao encontrado | Verifique CPF/CNPJ |
429 | Rate limit atingido | Aguarde e tente novamente |
500 | Erro interno | Contate o suporte |
Consultas paralelas
Para melhor performance, execute consultas independentes em paralelo:
Python (asyncio)
import asyncio
import aiohttp
async def investigar_pessoa(cpf: str, token: str):
base = "https://221b-api.sherlocker.com.br/api/v1"
async with aiohttp.ClientSession() as session:
endpoints = [
f"{base}/pessoas/cpf/{cpf}",
f"{base}/empresas/cpf/{cpf}",
f"{base}/veiculos/cpf/{cpf}",
f"{base}/dividas/cpf/{cpf}",
]
tasks = [
session.get(url, params={"token": token})
for url in endpoints
]
responses = await asyncio.gather(*tasks)
results = [await r.json() for r in responses]
return {
"pessoa": results[0],
"empresas": results[1],
"veiculos": results[2],
"dividas": results[3],
}
Node.js (Promise.all)
async function investigarPessoa(cpf, token) {
const base = "https://221b-api.sherlocker.com.br/api/v1";
const params = `?token=${token}`;
const [pessoa, empresas, veiculos, dividas] = await Promise.all([
fetch(`${base}/pessoas/cpf/${cpf}${params}`).then(r => r.json()),
fetch(`${base}/empresas/cpf/${cpf}${params}`).then(r => r.json()),
fetch(`${base}/veiculos/cpf/${cpf}${params}`).then(r => r.json()),
fetch(`${base}/dividas/cpf/${cpf}${params}`).then(r => r.json()),
]);
return { pessoa, empresas, veiculos, dividas };
}
Endpoints async
Modulos demorados (processos, perfis, bancos, cadastros) oferecem modo async:
# 1. Inicia o job
curl -X POST "https://221b-api.sherlocker.com.br/api/v1/processos/async/cpf/12345678900?token=SEU_TOKEN"
# Resposta: { "job_id": "abc123", "status": "processing" }
# 2. Consulta o status (repita ate "completed")
curl "https://221b-api.sherlocker.com.br/api/v1/processos/jobs/abc123?token=SEU_TOKEN"
# Resposta final: { "status": "completed", "results": [...] }
Polling em Python
import time
import requests
def executar_async(endpoint: str, cpf: str, token: str):
base = "https://221b-api.sherlocker.com.br/api/v1"
# Inicia o job
resp = requests.post(
f"{base}/{endpoint}/async/cpf/{cpf}",
params={"token": token}
)
job = resp.json()
job_id = job["job_id"]
# Polling
while True:
resp = requests.get(
f"{base}/{endpoint}/jobs/{job_id}",
params={"token": token}
)
result = resp.json()
if result["status"] == "completed":
return result["results"]
elif result["status"] == "error":
raise Exception(result.get("error", "Erro desconhecido"))
time.sleep(2)
Rate limits
| Plano | Limite |
|---|
| Padrao | 60 requests/minuto |
Ao atingir o limite, a API retorna 429 Too Many Requests. Implemente backoff exponencial:
import time
import requests
def request_with_retry(url, params, max_retries=3):
for attempt in range(max_retries):
response = requests.get(url, params=params)
if response.status_code == 429:
wait = 2 ** attempt # 1s, 2s, 4s
time.sleep(wait)
continue
return response.json()
raise Exception("Rate limit excedido apos retentativas")
Para integracao com tipagem e polling automatico, considere usar o SDK TypeScript.