cURL
curl --request GET \ --url https://garu.com.br/api/products \ --header 'Authorization: Bearer <token>'
{ "data": [ {} ], "count": 123, "page": 123, "totalPages": 123 }
Consulte todos os seus produtos cadastrados
tab
all
mine
affiliations
curl -X GET "https://garu.com.br/api/products?page=1&limit=10" \ -H "Authorization: Bearer sk_test_sua_chave_api"
{ "data": [ { "id": 123, "uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890", "name": "Curso de Marketing Digital", "description": "Aprenda marketing digital do zero", "value": 297.00, "pix": true, "creditCard": true, "boleto": true, "installments": [ { "quantity": 1, "value": 297.00 }, { "quantity": 2, "value": 153.45 } ], "isActive": true, "createdAt": "2024-12-24T10:30:00.000Z" }, { "id": 124, "uuid": "b2c3d4e5-f6a7-8901-bcde-f23456789012", "name": "E-book Python", "description": "Guia completo de Python", "value": 47.00, "pix": true, "creditCard": true, "boleto": false, "installments": [ { "quantity": 1, "value": 47.00 }, { "quantity": 2, "value": 24.30 } ], "isActive": true, "createdAt": "2024-12-23T15:00:00.000Z" } ], "count": 2, "page": 1, "totalPages": 1 }
async function listarTodosProdutos() { const produtos = []; let page = 1; let totalPages = 1; do { const response = await fetch( `https://garu.com.br/api/products?page=${page}&limit=50`, { headers: { 'Authorization': `Bearer ${process.env.GARU_API_KEY}` } } ); const result = await response.json(); produtos.push(...result.data); totalPages = result.totalPages; page++; } while (page <= totalPages); return produtos; }
Was this page helpful?