Inicio Rapido
Faca sua primeira chamada a API em menos de 5 minutos.
Prerequisitos
- Credenciais de acesso (email + senha) fornecidas pelo administrador
- URL do projeto Supabase:
https://<PROJECT>.supabase.co - Anon key do Supabase: disponivel no dashboard em Settings > API
Passo 1: Obter o token JWT
import requests
SUPABASE_URL = "https://<PROJECT>.supabase.co"
SUPABASE_ANON_KEY = "<ANON_KEY>"
EMAIL = "admin@empresa.com"
PASSWORD = "sua_senha"
resp = requests.post(
f"{SUPABASE_URL}/auth/v1/token?grant_type=password",
headers={"apikey": SUPABASE_ANON_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 SUPABASE_URL = "https://<PROJECT>.supabase.co";
const SUPABASE_ANON_KEY = "<ANON_KEY>";
const resp = await fetch(
`${SUPABASE_URL}/auth/v1/token?grant_type=password`,
{
method: "POST",
headers: {
apikey: SUPABASE_ANON_KEY,
"Content-Type": "application/json",
},
body: JSON.stringify({
email: "admin@empresa.com",
password: "sua_senha",
}),
}
);
const { access_token: token } = await resp.json();
console.log("Token obtido com sucesso");
export SUPABASE_URL="https://<PROJECT>.supabase.co"
export SUPABASE_ANON_KEY="<ANON_KEY>"
export BASE_URL="https://fast-deliv-backend.vercel.app"
TOKEN=$(curl -s -X POST \
"${SUPABASE_URL}/auth/v1/token?grant_type=password" \
-H "apikey: ${SUPABASE_ANON_KEY}" \
-H "Content-Type: application/json" \
-d '{"email":"admin@empresa.com","password":"sua_senha"}' \
| jq -r '.access_token')
echo "Token: ${TOKEN:0:20}..."
require 'net/http'
require 'json'
SUPABASE_URL = "https://<PROJECT>.supabase.co"
SUPABASE_ANON_KEY = "<ANON_KEY>"
uri = URI("#{SUPABASE_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'] = SUPABASE_ANON_KEY
req['Content-Type'] = 'application/json'
req.body = JSON.dump(email: 'admin@empresa.com', password: 'sua_senha')
resp = http.request(req)
token = JSON.parse(resp.body)['access_token']
puts "Token obtido com sucesso"
Passo 2: Verificar saude da API
Passo 3: Listar entregas
Passo 4: Criar sua primeira entrega
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']}"