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

# Python

> Integre a AbacatePay em aplicações Python em minutos.

<Card title="AbacatePay Python SDK" icon="github" href="https://github.com/AbacatePay/abacatepay-python-sdk">
  Repositório oficial — issues, changelog e contribuições.
</Card>

## Pré-requisitos

* Python 3.10+
* Uma chave de API ([criar no dashboard](https://app.abacatepay.com))

## Instalação

<CodeGroup>
  ```bash pip theme={null}
  pip install abacatepay
  ```

  ```bash poetry theme={null}
  poetry add abacatepay
  ```

  ```bash uv theme={null}
  uv add abacatepay
  ```
</CodeGroup>

## Configuração

Armazene sua chave de API em uma variável de ambiente e nunca no código:

```bash theme={null}
# .env
ABACATEPAY_API_KEY=sua_chave_aqui
```

```python theme={null}
import os
import abacatepay

client = abacatepay.AbacatePay(os.environ["ABACATEPAY_API_KEY"])
```

## Primeira cobrança

```python theme={null}
from abacatepay.products import Product

checkout = client.billing.create(
    products=[
        Product(
            external_id="PRO-PLAN",
            name="Pro plan",
            quantity=1,
            price=1000,  # em centavos
        )
    ],
    return_url="https://meusite.com/app",
    completion_url="https://meusite.com/pagamento/sucesso",
)

print(checkout.data.url)  # URL de pagamento para o cliente
```

**Resposta:**

```json theme={null}
{
  "success": true,
  "error": null,
  "data": {
    "id": "bill_12345667",
    "url": "https://app.abacatepay.com/pay/bill_12345667",
    "amount": 1000,
    "status": "PENDING",
    "devMode": true,
    "createdAt": "2024-11-04T18:38:28.573Z"
  }
}
```

## Próximos passos

<CardGroup cols={2}>
  <Card title="Configurar webhooks" icon="bell" href="/pages/webhooks">
    Receba notificações em tempo real sobre pagamentos confirmados.
  </Card>

  <Card title="Checkout Transparente" icon="credit-card" href="/pages/transparents/create">
    Aceite PIX e cartão diretamente na sua interface.
  </Card>

  <Card title="Criar clientes" icon="users" href="/pages/client/create">
    Gerencie clientes vinculados às cobranças.
  </Card>

  <Card title="Referência completa" icon="book-open" href="/pages/reference/introduction">
    Todos os endpoints, status codes e formato de resposta.
  </Card>
</CardGroup>
