const BASE = process.env.BS_API_BASE ?? "https://api.brazilscope.com";
const KEY = process.env.BS_API_KEY!;
type Envelope<T> =
| { success: true; data: T; meta?: { request_id: string } }
| { success: false; error: { code: string; message: string; request_id: string } };
export async function getCompany(cnpj: string): Promise<Envelope<unknown>> {
const res = await fetch(`${BASE}/api/v1/company/${cnpj}`, {
headers: { Authorization: `Bearer ${KEY}` },
next: { revalidate: 86400 },
});
return res.json();
}