A TypeScript client for the Trading212 API, designed to provide seamless access to Trading212’s endpoints for account data, equity orders, historical items, instruments metadata, personal portfolio, pies, and more.
Important
This library is not officially affiliated with Trading212.
- TypeScript-first: Strongly typed models and responses.
- Modular API: Access different API sections via API versioning e.g.,
v0. - Easy authentication: Pass your API key and environment (
demoorlive). - Convenient methods: For common Trading212 operations (pies, orders, account data, etc.).
npm install trading-212-client- Node.js >= 22
import Trading212 from 'trading-212-client'
const client = new Trading212({
apiKey: 'your-api-key',
environment: 'demo' // or 'live'
})
// Get all pies
const pies = await client.v0.pies.all()
// Get a specific pie
const pie = await client.v0.pies.get('pie-id')
// Delete a pie
await client.v0.pies.delete('pie-id')const client = new Trading212({ apiKey, environment })client.v0.accountDataclient.v0.equityOrdersclient.v0.historicalItemsclient.v0.instrumentsMetadataclient.v0.personalPortfolioclient.v0.pies
Each endpoint provides methods for interacting with the corresponding Trading212 API endpoints.
// List all pies
await client.v0.pies.all()
// Create a new pie
await client.v0.pies.create({
/* pie data */
})
// Update a pie
await client.v0.pies.update(pieId, {
/* update data */
})
// Delete a pie
await client.v0.pies.delete(pieId)All request and response types are exported from V0Types:
import { V0Types } from 'trading-212-client'- Install:
npm ci - Build:
npm run build - Format:
npx prettier --write .