dhanhq
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

DhanHQ-js : v1.0

npm js

NodeJS client for communicating with the DhanHQ API.

DhanHQ-js library can be used to integrate with Trading and Data APIs faster. Execute orders in real time along with position management, historical data, tradebook and more with simple API collection.

Dhan (c) 2022. Licensed under the MIT License

Documentation

Requirements

  • NodeJS v12.0.0+

Installation

Install via npm

npm install dhanhq@latest

Getting started with API

JS

var sdk = require("dhanhq");

const ACCESS_TOKEN = process.env.ACCESS_TOKEN;
const DHAN_CLIENT_ID = process.env.DHAN_CLIENT_ID;

const client = new sdk.DhanHqClient({
    accessToken: ACCESS_TOKEN,
    env: "PROD"
});

function getHoldings() {
    client.getHoldings().then(response => {
        console.log(response);
    }, err => {
        console.log(err)
    })
}

TS

import {
    DhanEnv,
    DhanHqClient
} from "dhanhq";

const ACCESS_TOKEN = process.env.ACCESS_TOKEN;
const DHAN_CLIENT_ID = process.env.DHAN_CLIENT_ID;

const client: DhanHqClient = new DhanHqClient({
    accessToken: ACCESS_TOKEN,
    env: DhanEnv.PROD
});

async function getHoldings() {
    try {
        const holdings = await client.getHoldings();
        console.log(holdings)
    } catch (exception) {
        console.log(exception)
    }
}

Package Sidebar

Install

npm i dhanhq

Weekly Downloads

7

Version

1.0.2

License

MIT

Unpacked Size

35.6 kB

Total Files

13

Last publish

Collaborators

  • vinaysd17