> ## Documentation Index
> Fetch the complete documentation index at: https://docs.cabrapi.com.br/llms.txt
> Use this file to discover all available pages before exploring further.

# Buscar Produtos

> Aprenda a listar produtos de uma loja usando o endpoint GET /stores/{storeId}/products.

## 📌 Endpoint

`GET /stores/{storeId}/products`

Retorna todos os produtos de uma loja.

Os produtos sao retornados na ordem de `position` (ascendente).

Produtos com `disabled: true` podem aparecer na resposta para uso no painel/admin.

***

## 🔐 Autenticação

* **Rota pública** para consulta.
* A loja precisa existir e estar com plano ativo.

***

## 🧾 Parâmetros de rota

| Parâmetro | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `storeId` | string | Sim | ID da loja |

***

## ✅ Exemplo de requisição

```bash theme={null}
curl -X GET "https://api.cabrapi.com.br/v1/stores/STORE_ID/products?page=1&limit=20"
```

***

## 🔎 Query params

| Parâmetro | Tipo | Obrigatório | Descrição |
| - | - | - | - |
| `page` | number | Não | Página atual (padrão: `1`) |
| `limit` | number | Não | Itens por página (padrão: `20`, máximo: `100`) |
| `cursor` | string | Não | Cursor opaco para paginação por cursor. Use o `nextCursor` da resposta anterior. Não pode ser usado junto com `page` |

***

## 🔄 Paginação por cursor

Para listas grandes (mais de \~100 itens), prefira paginação por **cursor** no lugar de `page`:

1. Faça a primeira chamada **sem** `cursor`.
2. Se `hasMore` for `true`, a resposta traz o campo `nextCursor`.
3. Envie esse `nextCursor` no parâmetro `cursor` da próxima requisição para buscar a página seguinte.

```bash theme={null}
curl -X GET "https://api.cabrapi.com.br/v1/stores/STORE_ID/products?cursor=v1:SEU_CURSOR_AQUI&limit=20"
```

No modo cursor, a paginação é retornada apenas com `nextCursor`, `hasMore` e `limit`:

```json theme={null}
{
	"code": "PRODUCTS_FETCHED",
	"products": [],
	"pagination": {
		"nextCursor": "v1:e2xFn...",
		"hasMore": true,
		"limit": 20
	}
}
```

* `cursor` e `page` **não podem** ser usados juntos (`400 INVALID_PAGINATION`).
* `nextCursor: null` com `hasMore: false` indicam o fim da lista (a API responde `200` com array vazio).

***

## 📦 Resposta de sucesso (200)

```json theme={null}
{
	"code": "PRODUCTS_FETCHED",
	"products": [
		{
			"id": "d4f2b5ff-7ae5-4a00-8f18-5d7b6f20f2b8",
			"name": "Curso Premium",
			"disabled": false,
			"position": 1,
			"description": "Acesso completo ao conteúdo.",
			"price": 49.9,
			"image": null,
			"delivery": "DIGITAL",
			"stock": 100,
			"sold": 12,
			"storeId": "STORE_ID",
			"metadata": {},
			"createdAt": "2026-03-02T20:00:00.000Z",
			"updatedAt": "2026-03-02T20:00:00.000Z",
			"categories": [
				{
					"id": "CATEGORY_ID",
					"name": "Cursos"
				}
			]
		}
	],
	"pagination": {
		"page": 1,
		"limit": 20,
		"total": 1,
		"totalPages": 1,
		"nextCursor": null,
		"hasMore": false
	}
}
```

> A primeira chamada (sem `cursor`) já retorna `nextCursor` e `hasMore` na paginação, permitindo iniciar a paginação por cursor sem chamadas extras.

***

## ⚠️ Possíveis erros

* `400 INVALID_DATA` → parâmetro inválido
* `400 INVALID_PAGINATION_LIMIT` → `limit` fora do intervalo permitido (`1` a `100`)
* `400 INVALID_PAGINATION_PAGE` → `page` inválida
* `400 INVALID_PAGINATION_CURSOR` → `cursor` inválido ou malformado
* `400 INVALID_PAGINATION` → `page` e `cursor` utilizados juntos
* `401 UNAUTHENTICATED` → não foi possível identificar o usuário da assinatura
* `403 NO_ACTIVE_SUBSCRIPTION` → plano inativo ou expirado
* `404 STORE_NOT_FOUND` → loja não encontrada
* `404 PRODUCTS_NOT_FOUND` → nenhum produto cadastrado (no modo offset quando `total` é `0`; no modo cursor retorna `200` com `[]`)
* `429 RATE_LIMIT_EXCEEDED` → limite de requisições por minuto excedido
* `500 INTERNAL_SERVER_ERROR` → erro interno
* `503 SERVICE_UNAVAILABLE` → serviço ou banco de dados indisponível


## OpenAPI

````yaml GET /stores/{storeId}/products
openapi: 3.1.0
info:
  title: caBRAPI
  version: 1.0.0
servers:
  - url: https://api.cabrapi.com.br/v1
security: []
paths:
  /stores/{storeId}/products:
    get:
      tags:
        - Products
      summary: List products
      operationId: listProducts
      parameters:
        - $ref: '#/components/parameters/StoreId'
        - in: query
          name: page
          schema:
            default: 1
            minimum: 1
            type: integer
        - in: query
          name: limit
          schema:
            default: 20
            maximum: 100
            minimum: 1
            type: integer
        - description: Opaque cursor from previous page (do not combine with page).
          in: query
          name: cursor
          schema:
            type: string
      responses:
        '200':
          content:
            application/json:
              schema:
                properties:
                  code:
                    example: PRODUCTS_FETCHED
                    type: string
                  products:
                    type: array
                    items:
                      $ref: '#/components/schemas/Product'
                  pagination:
                    $ref: '#/components/schemas/Pagination'
                required:
                  - code
                  - products
                  - pagination
                type: object
          description: List products.
        '400':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Invalid request.
        '401':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Unauthorized (missing store owner or unavailable database).
        '403':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Forbidden (inactive plan or insufficient permissions).
        '404':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Resource not found.
        '429':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Rate limit exceeded.
        '500':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Internal server error.
        '503':
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
          description: Service unavailable.
      security: []
components:
  parameters:
    StoreId:
      in: path
      name: storeId
      required: true
      schema:
        type: string
        minLength: 1
        maxLength: 50
  schemas:
    Product:
      description: Store product.
      properties:
        categories:
          items:
            properties:
              id:
                format: uuid
                type: string
              name:
                type: string
            required:
              - id
              - name
            type: object
          type: array
        createdAt:
          format: date-time
          type: string
        delivery:
          enum:
            - DIGITAL
            - PHYSICAL
          type: string
        description:
          nullable: true
          type: string
        disabled:
          type: boolean
        id:
          format: uuid
          type: string
        image:
          nullable: true
          type: string
        metadata:
          nullable: true
          type: object
        name:
          type: string
        position:
          type: integer
        price:
          type: number
        sold:
          type: integer
        stock:
          type: integer
        storeId:
          format: uuid
          type: string
        updatedAt:
          format: date-time
          type: string
      required:
        - id
        - name
        - position
        - price
        - delivery
        - stock
        - sold
        - storeId
        - disabled
        - createdAt
        - updatedAt
        - categories
      type: object
    Pagination:
      properties:
        hasMore:
          type: boolean
        limit:
          type: integer
        nextCursor:
          nullable: true
          type: string
        page:
          type: integer
        total:
          type: integer
        totalPages:
          type: integer
      type: object
    Error:
      properties:
        code:
          example: STORE_NOT_FOUND
          type: string
      required:
        - code
      type: object

````

This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.