Trading212 API

Ben Timor

Trading212 API

This is an unofficial selenium based API for 'Trading212' broker. Neither me and neither Trading212 are responsible for the API, You are responsible for your actions and for using the API.
Additionally, Note the Trading212 'Robo Trading' agreement.

Requirements

Python 3.x
Selenium package
GeckoDriver
FireFox browser

Installation

pip install trading212

Import

CFD mode:
Invest mode:

Usage

First of all, You have to know that the API currently uses the display name of the stocks.

Buying a stock ('Long')

trading.buy_stock(stock, amount)

Selling a stock ('Short')

trading.sell_stock(stock, amount) # Available for CFD only

Closing a position

trading.close_position(stock)

Getting a result of a position

trading.result(stock)

Getting another information of a position

trading.position_info(css_class)
You can get anything that's written in the bar. I've added a picture with source code so you'll be able to select the class.
Like this project

Posted Jul 20, 2024

An unofficial API for Trading212. Contribute to BenTimor/Trading212API development by creating an account on GitHub.

Kenny - Ingredient Scanner
Kenny - Ingredient Scanner
Qeres - The easiest and most flexible way to create APIs
Qeres - The easiest and most flexible way to create APIs

Join 50k+ companies and 1M+ independents

Contra Logo

© 2025 Contra.Work Inc