Listar Produtos
curl --request GET \
--url https://garu.com.br/api/products \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/products"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://garu.com.br/api/products', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://garu.com.br/api/products",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://garu.com.br/api/products"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://garu.com.br/api/products")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/products")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{}
],
"count": 123,
"page": 123,
"totalPages": 123
}Produtos
Listar Produtos
Consulte todos os seus produtos cadastrados
GET
/
api
/
products
Listar Produtos
curl --request GET \
--url https://garu.com.br/api/products \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/products"
headers = {"Authorization": "Bearer <token>"}
response = requests.get(url, headers=headers)
print(response.text)const options = {method: 'GET', headers: {Authorization: 'Bearer <token>'}};
fetch('https://garu.com.br/api/products', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://garu.com.br/api/products",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://garu.com.br/api/products"
req, _ := http.NewRequest("GET", url, nil)
req.Header.Add("Authorization", "Bearer <token>")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.get("https://garu.com.br/api/products")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/products")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Authorization"] = 'Bearer <token>'
response = http.request(request)
puts response.read_body{
"data": [
{}
],
"count": 123,
"page": 123,
"totalPages": 123
}Visão Geral
Este endpoint retorna uma lista paginada de todos os seus produtos. Você pode filtrar por tipo de produto usando o parâmetrotab.
Parâmetros de Query
Número da página para paginação.
Quantidade de itens por página (máximo 100).
Filtro de produtos:
all- Todos os produtosmine- Apenas seus produtosaffiliations- Produtos que você é afiliado
Exemplo de Requisição
curl -X GET "https://garu.com.br/api/products?page=1&limit=10" \
-H "Authorization: Bearer sk_test_sua_chave_api"
const response = await fetch(
'https://garu.com.br/api/products?page=1&limit=10',
{
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`
}
}
);
const { data, count, page, totalPages } = await response.json();
data.forEach(product => {
console.log(`${product.name}: https://garu.com.br/pay/${product.uuid}`);
});
import requests
import os
url = "https://garu.com.br/api/products"
headers = {
"Authorization": f"Bearer {os.environ['GARU_API_KEY']}"
}
params = {
"page": 1,
"limit": 10
}
response = requests.get(url, headers=headers, params=params)
result = response.json()
for product in result['data']:
print(f"{product['name']}: https://garu.com.br/pay/{product['uuid']}")
Resposta de Sucesso
Lista de produtos.
Total de produtos retornados nesta página.
Página atual.
Total de páginas disponíveis.
Exemplo de Resposta (200 OK)
{
"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
}
Paginação
Para percorrer todas as páginas de produtos: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;
}
Próximos Passos
Atualizar Produto
Atualize os dados de um produto existente
Excluir Produto
Desative um produto
Was this page helpful?
⌘I