Unofficial IG Trading API for Node.js, written in TypeScript and covered by tests.
npm
npm install ig-trading-api
Yarn
yarn add ig-trading-api
You can set the API gateway, when initializing the API client. Use APIClient.URL_DEMO
(demo-api.ig.com) for demo accounts and APIClient.URL_LIVE
(api.ig.com) for live account access.
import {APIClient} from 'ig-trading-api';
const client = new APIClient(APIClient.URL_LIVE, {
apiKey: 'your-api-key',
username: 'your-username',
password: 'your-password',
});
Make sure to use IG's Epic codes to find a trading symbol:
const query = 'BITCOIN';
const response = await client.rest.market.searchMarkets(query);
console.log(response.markets[0].epic);
Check the available intervals for retrieving data:
import {APIClient, Resolution} from 'ig-trading-api';
console.log(Resolution);
const epic = 'UC.D.MSFT.CASH.IP';
const prices = await client.rest.market.price.getPrices(epic, Resolution.DAY, 5);
Here is how you can subscribe to live candles and other updates from IG:
More code examples can be found in the demo directory.
Breakdown for "IX.D.DOW.DAILY.IP":
Symbol | Description | Example |
---|---|---|
IX | Hours of trading | "Index Out of Hours" |
D | Tradability | "D" when tradeable |
DOW | Underlying market | "Dow Jones" |
DAILY | Indicator for processing method | "Daily" funded bet |
IP | Asset type | "Intellectual Property" |
Epics for testing:
Epic | Name | Environment | Trading Time |
---|---|---|---|
ED.D.DHERGY.CASH.IP | Delivery Hero SE | Live / Demo | Germany: 09:00 - 17:30 |
UC.D.MSFT.CASH.IP | Microsoft Corp | Live / Demo | Germany: 10:00 - 03:00 |
UA.D.COINUS.CASH.IP | Coinbase Global Inc | Live | Germany: 15:30 - 22:00 |
You can get up and running in just a few simple steps:
yarn
(to install or update third-party dependencies).env
in the root directory of this repository (read more about dotenv files)yarn demo:login
to test your credentialsContributions, issues and feature requests are welcome!
Feel free to check the issues page.
This project is MIT licensed.
Please leave a star if you find this project useful.