Client não oficial da API do Santander em Python
Project description
Santander Python SDK
An unofficial Python SDK for Santander's API that simplifies integration with Santander banking services.
Features
- ✨ Authentication: Automatic token management
- 💰 Account Information: Retrieve account and workspace details
- 💸 PIX Transfers: Easy PIX payment processing
- 📑 Receipts: Query and retrieve receipts of any transaction
- 📊 Transaction History: Query and track transactions history
- 🔒 Secure: Built-in security best practices
Installation
pip install santander-python-sdk
Quick Start
from decimal import Decimal
from santander_sdk import SantanderApiClient, SantanderClientConfiguration
# Initialize the client
client = SantanderApiClient(
SantanderClientConfiguration(
client_id="your_client_id",
client_secret="your_client_secret",
cert="path_to_certificate",
base_url="api_url",
workspace_id="optional_workspace_id"
)
)
# Make a simple PIX transfer
from santander_sdk import transfer_pix
transfer = transfer_pix(
client,
pix_key="recipient@email.com",
value=Decimal("50.00"),
description="Lunch payment"
)
# Check transfer status
from santander_sdk import get_transfer
status = get_transfer(transfer["id"])
print(f"Transfer status: {status['status']}")
Advanced Usage
PIX Transfer to Bank Account
from santander_sdk import SantanderBeneficiary
# Create beneficiary
beneficiary = SantanderBeneficiary(
name="John Doe",
bankCode="404", # Santander bank code
branch="2424",
number="123456789", # Account number with check digit
type="CONTA_CORRENTE",
documentType="CPF",
documentNumber="12345678909"
)
# Make transfer
transfer = transfer_pix(
client,
beneficiary,
value=Decimal("100.00"),
description="Rent payment"
)
List Payments to get useful information
You can get the list of payments made, filtering by payment type, recipient, etc. See ListPaymentParams for all possible filters. One use case, for example, is when you want to generate a receipt but don't have the payment ID.
from santander_sdk import payment_list, ListPaymentParams
payments = payment_list(client, ListPaymentParams(
start_date="2025-01-01",
end_date="2025-01-02",
))
payment_id = payments[0]["payment"]["paymentId"]
Create a Receipt Request
Create a receipt request using the payment ID.
from santander_sdk import create_receipt
create_response = create_receipt(client, "MY-PAYMENT-ID")
The receipt creation is asynchronous on Santander. You will likely receive a response indicating that your receipt has been requested. Since the process is asynchronous, you should check back later to retrieve it.
Get the Receipt Information/URL
To obtain the receipt information, you need the payment id and the receipt_request_id (which is generated when you made the request on create_receipt).
from santander_sdk import get_receipt
receipt_info = get_receipt(client, payment_id, receipt_request_id)
print('Receipt Status:', receipt_info["status"])
print('Receipt URL Location:', receipt_info["location"])
print('Full Information:', receipt_info["data"])
Advanced usage of Receipts
Iterate Over Payments List
If the payments list is too large and you want to iterate over them, use payment_list_iter_by_pages.
from santander_sdk import payment_list_iter_by_pages, ListPaymentParams
# Filtering by one month with a return of 2 payments per page, the max per page is 1000
payments_pages = payment_list_iter_by_pages(client, ListPaymentParams(
start_date="2025-02-01",
end_date="2025-02-28",
_limit="2")
)
for page in payments_pages:
print('Page:', page)
Obtain Receipt Creation History
To obtain the history of receipt creation:
from santander_sdk.payment_receipts import receipt_creation_history
history = receipt_creation_history(client, payment_id)
print('Receipt Creation History:', history)
This function is used internally to handle cases where a receipt request has expired or encountered an error. However, you can use it to view all receipt creation requests that have been made.
Contributing
We welcome contributions! Here's how you can help:
Setting up Development Environment
- Clone the repository
git clone https://github.com/yourusername/santander-python-sdk
cd santander-python-sdk
- Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install development dependencies
pip install -e ".[dev]"
Development Guidelines
- Write tests for new features using pytest
- Follow PEP 8 style guide
- Add docstrings to new functions and classes
- Update documentation when adding features
Running Tests
pytest tests/
Submitting Changes
- Fork the repository
- Create a new branch (
git checkout -b feature/amazing-feature) - Make your changes
- Run tests
- Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Support
- 📫 Open an issue for bugs or feature requests
- 💬 Join our Discord community for discussions
- 📖 Check our FAQ for common questions
Santander oficial documentation
License
This project is licensed under the MIT License - see the LICENSE file for details.
Security
For security concerns, please email foss@buser.com.br.
Acknowledgments
- Thanks to all contributors who have helped shape this SDK
- Built with support from the Python community
⭐ If you find this SDK helpful, please star the repository!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file santander_python_sdk-0.4.1.tar.gz.
File metadata
- Download URL: santander_python_sdk-0.4.1.tar.gz
- Upload date:
- Size: 51.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
80ed942151df7a6c9cf864f153c6acc26c282bc1a1e39a7adade96e96dc4ac24
|
|
| MD5 |
f0f1d226edc08028e556aed7c308356d
|
|
| BLAKE2b-256 |
82dad3e8d260b91d9245a33428cdbd85fb912eb1e3b45779c69d0322cafbd403
|
Provenance
The following attestation bundles were made for santander_python_sdk-0.4.1.tar.gz:
Publisher:
test.yml on buserbrasil/santander-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
santander_python_sdk-0.4.1.tar.gz -
Subject digest:
80ed942151df7a6c9cf864f153c6acc26c282bc1a1e39a7adade96e96dc4ac24 - Sigstore transparency entry: 530549004
- Sigstore integration time:
-
Permalink:
buserbrasil/santander-python-sdk@59da6f1cec55902759a62d715112721991395740 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/buserbrasil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@59da6f1cec55902759a62d715112721991395740 -
Trigger Event:
push
-
Statement type:
File details
Details for the file santander_python_sdk-0.4.1-py3-none-any.whl.
File metadata
- Download URL: santander_python_sdk-0.4.1-py3-none-any.whl
- Upload date:
- Size: 22.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1377c1f2de3382f9aea0c6116a879c19b50b9b8be57d8c8b59a086b0353c5ecf
|
|
| MD5 |
e127b7574872d10e1eb4d3441b0af4f0
|
|
| BLAKE2b-256 |
3318a28d02d506528da080ef08dc7dbdf958dee2011b0196613cdf93d8a642a2
|
Provenance
The following attestation bundles were made for santander_python_sdk-0.4.1-py3-none-any.whl:
Publisher:
test.yml on buserbrasil/santander-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
santander_python_sdk-0.4.1-py3-none-any.whl -
Subject digest:
1377c1f2de3382f9aea0c6116a879c19b50b9b8be57d8c8b59a086b0353c5ecf - Sigstore transparency entry: 530549009
- Sigstore integration time:
-
Permalink:
buserbrasil/santander-python-sdk@59da6f1cec55902759a62d715112721991395740 -
Branch / Tag:
refs/tags/v0.4.1 - Owner: https://github.com/buserbrasil
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
test.yml@59da6f1cec55902759a62d715112721991395740 -
Trigger Event:
push
-
Statement type: