Skip to main content

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 with aiohttp
  • Trading212Client: sync client built with requests

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 await inside 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

trading_212_client-0.1.4.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trading_212_client-0.1.4-py3-none-any.whl (10.0 kB view details)

Uploaded Python 3

File details

Details for the file trading_212_client-0.1.4.tar.gz.

File metadata

  • Download URL: trading_212_client-0.1.4.tar.gz
  • Upload date:
  • Size: 8.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for trading_212_client-0.1.4.tar.gz
Algorithm Hash digest
SHA256 b6d579c4f8a2412602ce55cdf7c90b8edcf67c538b441cc0bd4d5e18ffe0393a
MD5 284752cd0874b801754e9ccbd1e9f7c5
BLAKE2b-256 45ee024fd41978132883646498a2a660c9ed89ca9e4243e7df9d570be24510c2

See more details on using hashes here.

Provenance

The following attestation bundles were made for trading_212_client-0.1.4.tar.gz:

Publisher: python-publish.yml on Lancasterg/python-trading-212

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file trading_212_client-0.1.4-py3-none-any.whl.

File metadata

File hashes

Hashes for trading_212_client-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d7a35997db664fea746e1eb57e2bcaca920f607ec679da33ce13f9b63de1cbe0
MD5 e36999d9762377bfaee25016ff4a9690
BLAKE2b-256 567477d1c2e9fb5a1b34bef3f32e23e2333c21a9c4d6ae222db1aa2c49cafc46

See more details on using hashes here.

Provenance

The following attestation bundles were made for trading_212_client-0.1.4-py3-none-any.whl:

Publisher: python-publish.yml on Lancasterg/python-trading-212

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page