Início Rápido
Faça sua primeira chamada à API em menos de 5 minutos.
Pré-requisitos
O administrador da plataforma fornecerá:
- Email e senha — suas credenciais de acesso
AUTH_URL— URL do serviço de autenticaçãoAUTH_PUBLIC_KEY— chave pública para autenticação
Passo 1: Obter o token JWT
- Python
- JavaScript
- Shell
- Ruby
import requests
AUTH_URL = "<AUTH_URL>"
AUTH_PUBLIC_KEY = "<AUTH_PUBLIC_KEY>"
EMAIL = "usuario@empresa.com"
PASSWORD = "sua_senha"
resp = requests.post(
f"{AUTH_URL}/auth/v1/token?grant_type=password",
headers={"apikey": AUTH_PUBLIC_KEY, "Content-Type": "application/json"},
json={"email": EMAIL, "password": PASSWORD},
)
resp.raise_for_status()
token = resp.json()["access_token"]
print("Token obtido com sucesso")
const AUTH_URL = "<AUTH_URL>";
const AUTH_PUBLIC_KEY = "<AUTH_PUBLIC_KEY>";
const resp = await fetch(
`${AUTH_URL}/auth/v1/token?grant_type=password`,
{
method: "POST",
headers: {
apikey: AUTH_PUBLIC_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "usuario@empresa.com",
password: "sua_senha",
}),
}
);
const { access_token: token } = await resp.json();
console.log("Token obtido com sucesso");
export AUTH_URL="<AUTH_URL>"
export AUTH_PUBLIC_KEY="<AUTH_PUBLIC_KEY>"
export BASE_URL="https://api-fastdelivery.obotzap.com"
TOKEN=$(curl -s -X POST \
"${AUTH_URL}/auth/v1/token?grant_type=password" \
-H "apikey: ${AUTH_PUBLIC_KEY}" \
-H "Content-Type: application/json" \
-d '{"email":"usuario@empresa.com","password":"sua_senha"}' \
| jq -r '.access_token')
echo "Token: ${TOKEN:0:20}..."
require 'net/http'
require 'json'
AUTH_URL = "<AUTH_URL>"
AUTH_PUBLIC_KEY = "<AUTH_PUBLIC_KEY>"
uri = URI("#{AUTH_URL}/auth/v1/token?grant_type=password")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
req = Net::HTTP::Post.new(uri)
req['apikey'] = AUTH_PUBLIC_KEY
req['Content-Type'] = 'application/json'
req.body = JSON.dump(email: 'usuario@empresa.com', password: 'sua_senha')
resp = http.request(req)
token = JSON.parse(resp.body)['access_token']
puts "Token obtido com sucesso"
Passo 2: Verificar saúde da API
- Python
- JavaScript
- Shell
- Ruby
BASE_URL = "https://api-fastdelivery.obotzap.com"
resp = requests.get(f"{BASE_URL}/health")
print(resp.json()) # {"status": "ok"}
const BASE_URL = "https://api-fastdelivery.obotzap.com";
const resp = await fetch(`${BASE_URL}/health`);
console.log(await resp.json()); // { status: "ok" }
curl -s "${BASE_URL}/health" | jq .
# { "status": "ok" }
BASE_URL = "https://api-fastdelivery.obotzap.com"
uri = URI("#{BASE_URL}/health")
resp = Net::HTTP.get_response(uri)
puts JSON.parse(resp.body).inspect
# {"status"=>"ok"}
Passo 3: Listar entregas
- Python
- JavaScript
- Shell
- Ruby
headers = {"Authorization": f"Bearer {token}"}
resp = requests.get(f"{BASE_URL}/api/v1/deliveries", headers=headers)
resp.raise_for_status()
deliveries = resp.json()
for d in deliveries:
print(f"{d['id']} | {d['status']} | {d['title']}")
const headers = { Authorization: `Bearer ${token}` };
const resp = await fetch(`${BASE_URL}/api/v1/deliveries`, { headers });
const deliveries = await resp.json();
deliveries.forEach((d) => {
console.log(`${d.id} | ${d.status} | ${d.title}`);
});
curl -s "${BASE_URL}/api/v1/deliveries" \
-H "Authorization: Bearer ${TOKEN}" \
| jq '.[] | {id, status, title}'
uri = URI("#{BASE_URL}/api/v1/deliveries")
req = Net::HTTP::Get.new(uri)
req['Authorization'] = "Bearer #{token}"
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
resp = http.request(req)
JSON.parse(resp.body).each do |d|
puts "#{d['id']} | #{d['status']} | #{d['title']}"
end
Passo 4: Criar sua primeira entrega
- Python
- JavaScript
- Shell
- Ruby
payload = {
"title": "Entrega Centro",
"origin_address": "Rua das Flores, 100, Goiania",
"origin_lat": -16.6869,
"origin_lng": -49.2648,
"destination_address": "Av. Anhanguera, 500, Goiania",
"destination_lat": -16.6643,
"destination_lng": -49.2744,
}
resp = requests.post(
f"{BASE_URL}/api/v1/deliveries",
headers=headers,
json=payload,
)
resp.raise_for_status()
delivery = resp.json()
print(f"Entrega criada: {delivery['id']} — status: {delivery['status']}")
const payload = {
title: "Entrega Centro",
origin_address: "Rua das Flores, 100, Goiania",
origin_lat: -16.6869,
origin_lng: -49.2648,
destination_address: "Av. Anhanguera, 500, Goiania",
destination_lat: -16.6643,
destination_lng: -49.2744,
};
const resp = await fetch(`${BASE_URL}/api/v1/deliveries`, {
method: "POST",
headers: { ...headers, "Content-Type": "application/json" },
body: JSON.stringify(payload),
});
const delivery = await resp.json();
console.log(`Entrega criada: ${delivery.id} — status: ${delivery.status}`);
curl -s -X POST "${BASE_URL}/api/v1/deliveries" \
-H "Authorization: Bearer ${TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"title": "Entrega Centro",
"origin_address": "Rua das Flores, 100, Goiania",
"origin_lat": -16.6869,
"origin_lng": -49.2648,
"destination_address": "Av. Anhanguera, 500, Goiania",
"destination_lat": -16.6643,
"destination_lng": -49.2744
}' | jq '{id, status, title}'
uri = URI("#{BASE_URL}/api/v1/deliveries")
req = Net::HTTP::Post.new(uri)
req['Authorization'] = "Bearer #{token}"
req['Content-Type'] = 'application/json'
req.body = JSON.dump(
title: 'Entrega Centro',
origin_address: 'Rua das Flores, 100, Goiania',
origin_lat: -16.6869,
origin_lng: -49.2648,
destination_address: 'Av. Anhanguera, 500, Goiania',
destination_lat: -16.6643,
destination_lng: -49.2744
)
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
resp = http.request(req)
delivery = JSON.parse(resp.body)
puts "Entrega criada: #{delivery['id']} — status: #{delivery['status']}"