{"_id":"@azaini/t212-sdk","_rev":"2-f8a6353b7889c819b57ae01ba38aa91e","name":"@azaini/t212-sdk","dist-tags":{"latest":"0.1.1"},"versions":{"0.1.0":{"name":"@azaini/t212-sdk","version":"0.1.0","keywords":["trading212","trading 212","t212","trading","stocks","sdk","api"],"license":"MIT","_id":"@azaini/t212-sdk@0.1.0","maintainers":[{"name":"azaini","email":"alimzaini@outlook.com"}],"homepage":"https://github.com/zaini/trading212-sdk#readme","bugs":{"url":"https://github.com/zaini/trading212-sdk/issues"},"dist":{"shasum":"aca00cea24344aa3c4cba0de36aa8d59ec9cb01a","tarball":"https://registry.npmjs.org/@azaini/t212-sdk/-/t212-sdk-0.1.0.tgz","fileCount":9,"integrity":"sha512-MBmOSzNTtcuJJdkGegPymlNi7p7igtjWe061+T0I/Be+4CJFwPIhdrgXuGZJp0HGRNV5E88Y6oIhiGsmvUlkBQ==","signatures":[{"sig":"MEQCIGZ1TiObLvt/qJvGgT4+dqR8MnmidtLmMmJDKRVjiJOcAiAf4jYg+fvOm/ADHAV1wM2gz3vw068iWjDoYVBJI/s/kA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":1060942},"main":"./dist/index.cjs","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"1f0ecd06b6e60bbcccf71c3ebef84a75564d76cf","scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"_npmUser":{"name":"azaini","email":"alimzaini@outlook.com"},"repository":{"url":"git+https://github.com/zaini/trading212-sdk.git","type":"git","directory":"sdks/typescript"},"_npmVersion":"10.8.2","description":"Unofficial, fully typed TypeScript SDK for the Trading 212 Public API","directories":{},"sideEffects":false,"_nodeVersion":"20.20.2","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","vitest":"^3.2.0","typescript":"~5.9.0","@types/node":"^20.19.0"},"_npmOperationalInternal":{"tmp":"tmp/t212-sdk_0.1.0_1789082178779_0.9979180694401377","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"_id":"@azaini/t212-sdk@0.1.1","bugs":{"url":"https://github.com/zaini/trading212-sdk/issues"},"dist":{"shasum":"b0fadf13ef6dd2ef2a05310eed7f007da9da689e","tarball":"https://registry.npmjs.org/@azaini/t212-sdk/-/t212-sdk-0.1.1.tgz","fileCount":9,"integrity":"sha512-uwCIh4/h4wpHXB9YAJxGT+FY4yFKjVlntJMEifzdOffj70QXtbYFFG/JcWzHFZ2QdOGH5Jr66bnwItcfrxqjaw==","signatures":[{"sig":"MEQCIGHJjC/fX1Ks2CBJWIpckBwl8tykTvbk8c9p7HdFFiM1AiB0lDjUrVmSrqq4xAh3xWkbNHDV9fJgLA+WTN9cyNYFsQ==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIArqlahRGKpT8ffHzG8gdWn9KVdEzHGOjwPy11TYTrVJAiBtk/9GDIKvEty7cA+AEAiuA9DNpzHVH8MmFpL2osgn6w=="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@azaini%2ft212-sdk@0.1.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":1060942},"main":"./dist/index.cjs","name":"@azaini/t212-sdk","type":"module","types":"./dist/index.d.ts","module":"./dist/index.js","engines":{"node":">=18"},"exports":{".":{"import":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"require":{"types":"./dist/index.d.cts","default":"./dist/index.cjs"}}},"gitHead":"a96b66e869c33fe3f4c2e58ff63af8ec9f90ed62","license":"MIT","scripts":{"test":"vitest run","build":"tsup","typecheck":"tsc --noEmit","prepublishOnly":"npm run build"},"version":"0.1.1","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:92327076-989b-414a-8bf2-99d5fb3cb75b"}},"homepage":"https://github.com/zaini/trading212-sdk#readme","keywords":["trading212","trading 212","t212","trading","stocks","sdk","api"],"repository":{"url":"git+https://github.com/zaini/trading212-sdk.git","type":"git","directory":"sdks/typescript"},"_npmVersion":"12.0.2","description":"Unofficial, fully typed TypeScript SDK for the Trading 212 Public API","directories":{},"maintainers":[{"name":"azaini","email":"alimzaini@outlook.com"}],"sideEffects":false,"_nodeVersion":"24.20.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.5.0","vitest":"^3.2.0","typescript":"~5.9.0","@types/node":"^20.19.0"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/t212-sdk_0.1.1_1789082531515_0.11333976696016945"}}},"time":{"created":"2026-09-10T23:16:18.526Z","modified":"2026-09-10T23:22:11.917Z","0.1.0":"2026-09-10T23:16:18.955Z","0.1.1":"2026-09-10T23:22:11.607Z"},"bugs":{"url":"https://github.com/zaini/trading212-sdk/issues"},"license":"MIT","homepage":"https://github.com/zaini/trading212-sdk#readme","keywords":["trading212","trading 212","t212","trading","stocks","sdk","api"],"repository":{"url":"git+https://github.com/zaini/trading212-sdk.git","type":"git","directory":"sdks/typescript"},"description":"Unofficial, fully typed TypeScript SDK for the Trading 212 Public API","maintainers":[{"name":"azaini","email":"alimzaini@outlook.com"}],"readme":"# @azaini/t212-sdk\n\nTyped TypeScript/JavaScript client for the [Trading 212 Public API](https://docs.trading212.com/api),\ngenerated from Trading 212's OpenAPI spec. No runtime dependencies; ESM and CommonJS; Node 18+ or any runtime\nwith `fetch`. Unofficial and not affiliated with Trading 212.\n\n```sh\nnpm install @azaini/t212-sdk\n```\n\n## Usage\n\n```ts\nimport { Trading212Client, Trading212Environment } from \"@azaini/t212-sdk\";\n\nconst client = new Trading212Client({\n    environment: Trading212Environment.Demo, // default; Live trades real money\n    apiKey: \"...\", // optional: defaults to the T212_API_KEY env var\n    apiSecret: \"...\", // optional: defaults to the T212_API_SECRET env var\n});\n\nconst summary = await client.account.getSummary();\nconst positions = await client.positions.list();\n\nawait client.orders.placeMarket({ ticker: \"AAPL_US_EQ\", quantity: 1 }); // buy\nawait client.orders.placeMarket({ ticker: \"AAPL_US_EQ\", quantity: -1 }); // sell: negative quantity\n```\n\nRequest and response types are exported under the `Trading212` namespace (`Trading212.Position`,\n`Trading212.MarketRequest`, ...). Every method is listed in the\n[naming map](https://github.com/zaini/trading212-sdk/blob/main/docs/naming-map.md).\n\nThe API rejects browser (CORS) requests, so use this from a server, not a web page.\n\n## Pagination\n\nHistory methods return a `Page`, which fetches further pages as you iterate:\n\n```ts\nfor await (const item of await client.history.listOrders({ limit: 50 })) {\n    console.log(item.order?.ticker, item.order?.status);\n}\n```\n\nOr one page at a time with `page.data`, `page.hasNextPage()` and `await page.getNextPage()`.\n\n## Errors, retries and timeouts\n\nNon-2xx responses throw `Trading212Error`, or a subclass such as `Trading212.UnauthorizedError` or\n`Trading212.TooManyRequestsError`. `statusCode`, `body` and `rawResponse` hold the response details.\n\n```ts\nimport { Trading212 } from \"@azaini/t212-sdk\";\n\ntry {\n    await client.positions.list();\n} catch (e) {\n    if (e instanceof Trading212.TooManyRequestsError) {\n        console.log(e.rawResponse.headers.get(\"x-ratelimit-reset\"));\n    }\n}\n```\n\nReads are retried twice on 408, 429 and 5xx, waiting for the rate-limit reset where the API provides it.\nPOST requests (placing orders, requesting exports) are never retried, because a request that timed out may\nstill have gone through.\n\nSet `timeoutInSeconds` and `maxRetries` on the client, or per call as the last argument:\n`client.positions.list({}, { timeoutInSeconds: 10, abortSignal })`.\n\n## Deprecated endpoints\n\n`client.pies.*` still works, but Trading 212 no longer maintains the Pies API. These methods are marked\n`@deprecated`.\n\n## Before you trade\n\nRead the [API gotchas](https://github.com/zaini/trading212-sdk/blob/main/docs/api-gotchas.md):\nrate limits per account, 4-decimal quantity precision, ticker formats, what isn't available on demo, and more.\n","readmeFilename":"README.md"}