npm.io
1.1.0 • Published 4 years ago

ig-rest-api

Licence
MIT
Version
1.1.0
Deps
2
Size
6 kB
Vulns
23
Weekly
0

IG REST API JS Wrapper

Installation

yarn install ig-rest-api

Usage

1. Import library
// ES6
import IG from "ig-rest-api";
// Common
const IG = require("ig-rest-api");
2. Create a new instance
const ig = new IG(yourApiKey, isDemo);
3. Use

Using Promise

ig.login(username, password)
  .then((res) => {
    console.log(res);
    //
    ig.get("positions").then((positions) => {
      console.log("positions:", positions);
    });
  })
  .catch(console.error);

Using Async

try {
  await ig.login(username, password);
  const positions = await ig.get("positions");
  console.log("positions:", positions);
} catch (error) {
  console.error(error);
}

Keywords