# Consultar extrato — Delta Wallet

Liste entradas e saídas da carteira com filtros e paginação.

URL: https://deltaapplications.com.br/docs/extrato
Base da API: https://api.deltaapplications.com.br/api/v1/wallet

Exemplos fictícios; endpoints de produção. Chaves somente no servidor.

Endpoint: GET /statement

## Parâmetros de consulta

| Campo | Tipo | Obrigatório | Descrição |
| --- | --- | --- | --- |
| page | integer | Não | Página solicitada, a partir de 1. Padrão 1. |
| limit | integer | Não | Itens por página: 1 a 100. Padrão 20. |
| type | string | Não | all, in ou out. Padrão all. cash_in e cash_out são aliases. |
| status | string | Não | Filtro opcional pelo status registrado na movimentação. |

## Requisição

### GET /statement?page=1&limit=20&type=all

### TypeScript

```typescript
// Node.js 20+ · execute no servidor
const key = process.env.DELTA_WALLET_KEY;
if (!key) throw new Error("Defina DELTA_WALLET_KEY");

const response = await fetch("https://api.deltaapplications.com.br/api/v1/wallet/statement?page=1&limit=20&type=all", {
  method: "GET",
  headers: {
    "X-Wallet-Key": key,
    "Accept": "application/json",
  },
  signal: AbortSignal.timeout(15_000),
  redirect: "error",
});

const data: Record<string, unknown> = await response.json();
if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${data.error ?? "Falha na API"}`);
}
// Persista os IDs no seu servidor. Não registre chaves nem dados pessoais.
// Em timeout, repita o POST apenas com o mesmo Idempotency-Key ou consulte a operação.
```

### JavaScript

```javascript
// Node.js 20+ · execute no servidor
const key = process.env.DELTA_WALLET_KEY;
if (!key) throw new Error("Defina DELTA_WALLET_KEY");

const response = await fetch("https://api.deltaapplications.com.br/api/v1/wallet/statement?page=1&limit=20&type=all", {
  method: "GET",
  headers: {
    "X-Wallet-Key": key,
    "Accept": "application/json",
  },
  signal: AbortSignal.timeout(15_000),
  redirect: "error",
});

const data = await response.json();
if (!response.ok) {
  throw new Error(`HTTP ${response.status}: ${data.error ?? "Falha na API"}`);
}
// Persista os IDs no seu servidor. Não registre chaves nem dados pessoais.
// Em timeout, repita o POST apenas com o mesmo Idempotency-Key ou consulte a operação.
```

### Python

```python
# Python 3 · biblioteca padrão · execute no servidor
import json
import os
from urllib.error import HTTPError
from urllib.request import Request, HTTPRedirectHandler, build_opener

class NoRedirect(HTTPRedirectHandler):
    def redirect_request(self, req, fp, code, msg, headers, newurl):
        return None  # Do not forward credentials to another address.

key = os.environ["DELTA_WALLET_KEY"]
headers = {
    "X-Wallet-Key": key,
    "Accept": "application/json",
}
request = Request(
    "https://api.deltaapplications.com.br/api/v1/wallet/statement?page=1&limit=20&type=all",
    method="GET",
    headers=headers,
)

try:
    with build_opener(NoRedirect()).open(request, timeout=15) as response:
        data = json.load(response)
except HTTPError as error:
    # Preserve o status para diagnóstico, sem expor credenciais.
    raise RuntimeError(f"Delta Wallet: HTTP {error.code}") from error

# Use data no servidor. Em timeout, repita o POST só com o mesmo Idempotency-Key.
```

### Go

```go
// Go 1.20+ · biblioteca padrão
package main

import (
    "encoding/json"
    "fmt"
    "io"
    "net/http"
    "os"
    "time"
)

func run() error {
    key := os.Getenv("DELTA_WALLET_KEY")
    if key == "" { return fmt.Errorf("defina DELTA_WALLET_KEY") }
    client := &http.Client{
        Timeout: 15 * time.Second,
        CheckRedirect: func(req *http.Request, via []*http.Request) error {
            return http.ErrUseLastResponse
        },
    }
    req, err := http.NewRequest("GET", "https://api.deltaapplications.com.br/api/v1/wallet/statement?page=1&limit=20&type=all", nil)
    if err != nil { return err }
    req.Header.Set("X-Wallet-Key", key)
    req.Header.Set("Accept", "application/json")
    res, err := client.Do(req)
    if err != nil { return err } // Em timeout, repita só com o mesmo Idempotency-Key.
    defer res.Body.Close()
    if res.StatusCode < 200 || res.StatusCode >= 300 {
        return fmt.Errorf("Delta Wallet: HTTP %d", res.StatusCode)
    }
    var data map[string]any
    if err := json.NewDecoder(io.LimitReader(res.Body, 2 << 20)).Decode(&data); err != nil {
        return err
    }
    // Use data no servidor; persista IDs sem registrar segredos.
    return nil
}

func main() {
    if err := run(); err != nil {
        fmt.Fprintln(os.Stderr, err)
        os.Exit(1)
    }
}
```

### PHP

```php
<?php
// PHP 8+ com extensão cURL · execute no servidor
$key = getenv('DELTA_WALLET_KEY');
if (!$key) { throw new RuntimeException('Defina DELTA_WALLET_KEY'); }

$ch = curl_init('https://api.deltaapplications.com.br/api/v1/wallet/statement?page=1&limit=20&type=all');
curl_setopt_array($ch, [
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_CONNECTTIMEOUT => 5,
    CURLOPT_TIMEOUT => 15,
    CURLOPT_FOLLOWLOCATION => false,
    CURLOPT_HTTPHEADER => [
        'X-Wallet-Key: ' . $key,
        'Accept: application/json',
    ],
]);
$raw = curl_exec($ch);
$status = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$failed = $raw === false;
curl_close($ch);
if ($failed) { throw new RuntimeException('Falha de comunicação; repita só com o mesmo Idempotency-Key.'); }
if ($status < 200 || $status >= 300) {
    throw new RuntimeException('Delta Wallet: HTTP ' . $status);
}
$data = json_decode($raw, true, 512, JSON_THROW_ON_ERROR);
// Use $data no servidor. Não registre chaves nem dados pessoais.
```

### C#

```csharp
// C# · .NET 8 · aplicação de console no servidor
using System;
using System.Net.Http;
using System.Text;
using System.Text.Json;

var key = Environment.GetEnvironmentVariable("DELTA_WALLET_KEY")
    ?? throw new InvalidOperationException("Defina DELTA_WALLET_KEY");
using var handler = new HttpClientHandler { AllowAutoRedirect = false };
using var client = new HttpClient(handler) { Timeout = TimeSpan.FromSeconds(15) };
using var request = new HttpRequestMessage(new HttpMethod("GET"), "https://api.deltaapplications.com.br/api/v1/wallet/statement?page=1&limit=20&type=all");
request.Headers.Add("X-Wallet-Key", key);
request.Headers.Add("Accept", "application/json");

using var response = await client.SendAsync(request);
if (!response.IsSuccessStatusCode)
    throw new HttpRequestException($"Delta Wallet: HTTP {(int)response.StatusCode}");
using var data = JsonDocument.Parse(await response.Content.ReadAsStringAsync());
// Use data.RootElement no servidor. Não exponha credenciais.
// Em timeout, repita o POST só com o mesmo Idempotency-Key.
```

### cURL

```bash
curl --request GET 'https://api.deltaapplications.com.br/api/v1/wallet/statement?page=1&limit=20&type=all' \
  --max-time 15 \
  --header "X-Wallet-Key: $DELTA_WALLET_KEY" \
  --header 'Accept: application/json'
```

## Resposta

A paginação fica no objeto pagination. direction distingue credit e debit. Os totais de summary consideram movimentações concluídas do conjunto carregado.

Resposta ilustrativa (campos relevantes):

```json
{
  "success": true,
  "pagination": {
    "total": 1,
    "page": 1,
    "limit": 20,
    "totalPages": 1
  },
  "summary": {
    "totalEntradasReais": 25,
    "totalSaidasReais": 0
  },
  "transactions": [
    {
      "id": "pix_exemplo_1082",
      "direction": "credit",
      "type": "cash_in",
      "title": "Pix Recebido",
      "amountCentavos": 2500,
      "feeCentavos": 75,
      "netCentavos": 2425,
      "amount": 25,
      "fee": 0.75,
      "net": 24.25,
      "status": "approved",
      "date": "2026-10-25T12:05:00.000Z",
      "reference": "pedido-1082"
    }
  ]
}
```

> Recorte do extrato: A implementação atual carrega até 200 registros de cada tipo antes de paginar. Não use os totais desta resposta como uma exportação contábil completa de todo o histórico.
