Listar Produtos
curl --request GET \
--url https://garu.com.br/api/v1/products \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/v1/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/v1/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/v1/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/v1/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/v1/products")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/v1/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,
"totalCount": 123,
"totalPages": 123
}Produtos
Listar Produtos
Consulte todos os seus produtos cadastrados
GET
/
api
/
v1
/
products
Listar Produtos
curl --request GET \
--url https://garu.com.br/api/v1/products \
--header 'Authorization: Bearer <token>'import requests
url = "https://garu.com.br/api/v1/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/v1/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/v1/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/v1/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/v1/products")
.header("Authorization", "Bearer <token>")
.asString();require 'uri'
require 'net/http'
url = URI("https://garu.com.br/api/v1/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,
"totalCount": 123,
"totalPages": 123
}Visão Geral
Este endpoint retorna uma lista paginada de todos os seus produtos. Você pode filtrar por nome usando o parâmetrosearch.
Parâmetros de Query
number
default:"1"
Número da página para paginação.
number
default:"10"
Quantidade de itens por página.
string
Filtra os produtos pelo nome. Opcional.
Exemplo de Requisição
curl -X GET "https://garu.com.br/api/v1/products?page=1&limit=10" \
-H "Authorization: Bearer sk_test_sua_chave_api"
const response = await fetch(
'https://garu.com.br/api/v1/products?page=1&limit=10',
{
headers: {
'Authorization': `Bearer ${process.env.GARU_API_KEY}`
}
}
);
const { data, count, totalCount, 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/v1/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
array
Lista de produtos.
number
Total de produtos retornados nesta página.
number
Total de produtos que correspondem ao filtro, somando todas as páginas.
number
Total de páginas disponíveis.
Exemplo de Resposta (200 OK)
{
"data": [
{
"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"
},
{
"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,
"totalCount": 2,
"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/v1/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?