No project description provided
Project description
python-trading-212 (WIP)
A lightweight Python client for the Trading 212 API, providing both asynchronous and synchronous interfaces.
AsyncTrading212Client: async client built withaiohttpTrading212Client: sync client built withrequests
Installation
pip install trading-212-client
Configuration
Set your Trading 212 API key and environment as environment variables:
export T212_API_KEY=123_YOUR_API_KEY
export T212_ENVIRONMENT=live # or demo
Usage
AsyncTrading212Client
This client uses aiohttp for asynchronous requests.
from t212 import AsyncTrading212Client
import asyncio
async def main():
client = AsyncTrading212Client()
# Fetch account balance
cash = await client.fetch_account_cash()
print(cash.model_dump(mode="json"))
# Fetch exchanges
exchanges = await client.exchange_list()
print(exchanges.model_dump(mode="json"))
await client.close_client()
asyncio.run(main())
✅ Use
awaitinside an async function ✅ Always close the client when finished (close_client())
Trading212Client
This client uses requests for synchronous requests.
from t212 import Trading212Client
client = Trading212Client()
# Fetch account balance
cash = client.fetch_account_cash()
print(cash.model_dump(mode="json"))
# Fetch exchanges
exchanges = client.exchange_list()
print(exchanges.model_dump(mode="json"))
Features
- ✅ Fully typed responses (using Pydantic models)
- ✅ Both sync & async client implementations
- ✅ Easy environment setup via env vars
- 🚧 Work in progress (POST endpoints not yet implemented)
Roadmap
- All GET endpoints implemented for async client
- All POST endpoints implemented for async client
- All GET endpoints implemented for sync client
- All POST endpoints implemented for sync client
- Deploy on PyPI
- Add unit tests & CI pipeline
- Add usage examples for POST endpoints (when available)
Contributing
Contributions are welcome! Please open an issue or submit a pull request if you’d like to help improve the project.
Disclaimer
This library is unofficial and not affiliated with Trading 212. Use at your own risk. Trading involves risk of financial loss.
Project details
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 trading_212_client-0.1.2.tar.gz.
File metadata
- Download URL: trading_212_client-0.1.2.tar.gz
- Upload date:
- Size: 8.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f883dbfb25a55df87d6ad9d9f5d9fafdcce2597eead84076574ce5aa7c5ebd7
|
|
| MD5 |
73229f46d4438270ea1e3f6cf27c7853
|
|
| BLAKE2b-256 |
ecc0ad3bcca7bca8d335d470f243c34582d1f1fd3fbc7a1500ce9e6d541be4c6
|
Provenance
The following attestation bundles were made for trading_212_client-0.1.2.tar.gz:
Publisher:
python-publish.yml on Lancasterg/python-trading-212
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trading_212_client-0.1.2.tar.gz -
Subject digest:
7f883dbfb25a55df87d6ad9d9f5d9fafdcce2597eead84076574ce5aa7c5ebd7 - Sigstore transparency entry: 496577567
- Sigstore integration time:
-
Permalink:
Lancasterg/python-trading-212@cbd5d57c8ed522c9366554bc8053c2c79c44373a -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/Lancasterg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@cbd5d57c8ed522c9366554bc8053c2c79c44373a -
Trigger Event:
release
-
Statement type:
File details
Details for the file trading_212_client-0.1.2-py3-none-any.whl.
File metadata
- Download URL: trading_212_client-0.1.2-py3-none-any.whl
- Upload date:
- Size: 10.0 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 |
04330401c8d9845e8c6406d27f0b5468590f211f94f6675bf40176d26746fc2a
|
|
| MD5 |
7f9d5cdac7a5654672e7732ae46934a2
|
|
| BLAKE2b-256 |
85d94abc102bcc13c6f85b2d72c41934cb0d37a75c2dac5874a752abcbecac34
|
Provenance
The following attestation bundles were made for trading_212_client-0.1.2-py3-none-any.whl:
Publisher:
python-publish.yml on Lancasterg/python-trading-212
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
trading_212_client-0.1.2-py3-none-any.whl -
Subject digest:
04330401c8d9845e8c6406d27f0b5468590f211f94f6675bf40176d26746fc2a - Sigstore transparency entry: 496577589
- Sigstore integration time:
-
Permalink:
Lancasterg/python-trading-212@cbd5d57c8ed522c9366554bc8053c2c79c44373a -
Branch / Tag:
refs/tags/0.1.2 - Owner: https://github.com/Lancasterg
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@cbd5d57c8ed522c9366554bc8053c2c79c44373a -
Trigger Event:
release
-
Statement type: