npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

hargreaves-lansdown

v0.0.5

Published

An unofficial API to programatically access your Hargreaves Lansdown account

Downloads

7

Readme

UNOFFICIAL API

This is an unofficial API to programatically access your Hargreaves Lansdown account

Motivation

I wanted to programmatically access my ISA and share accounts with Hargreaves Lansdown, and they do not currently offer a developer API. This project spins up an endpoint that allows you to access your accounts in under 3 seconds

Install

npm install hargreaves-lansdown
yarn add hargreaves-lansdown

Usage

import HL from 'hargreaves-lansdown'

(async () => {
  const credentials = {
    username: "",
    password: "",
    dateOfBirth: "",
    secureNumber: "",
  };

  const hl = new HL();

  await hl.authenticate(credentials);

  console.log(await hl.getInDepth());

  await hl.logout();
})();

Things to note

This package is versioned according to SemVer. However, it is still in active development and ⚠️ versions < 1.0.0 are unstable and may potentially have breaking changes in every release. ⚠️ With this in mind, if you install this from NPM, make sure you pin your version of hargreaves-lansdown

If building & consuming from source, make sure you use a separate fork.

Contributing

I am open to suggestions / contributions for this package. It is very much in active development & I will be maintaining it for the foreseeable future. If you're not confident writing TypeScript / JavaScript, please don't let that hold you back- raise an issue with features you would like to see & I will endeavour to build & release them.

Commits

The commit styling adheres to the Conventional Commits specification. Please follow it! As well as being visually satisfying in the repo, it also serves a purpose for versioning releases correctly. When code is merged to the master branch, the commits in that pull request are analysed to determine whether the package version should be incremented by a major, minor or patch version.

Code style & standards

This repo uses Prettier, pretty standard nowadays (pardon the pun..!). ESLint is on the roadmap of being added.

Notes

getInDepth()

This method returns an object with the following interface:

interface IAccounts {
  [key: string]: IAccount | undefined;
}

interface IAccount {
  stockValue: string;
  cashValue: string;
  totalValue: string;
  available: string;
  holdings: IInvestments;
}

interface IInvestments {
  [key: string]: IInvestment;
}

interface IInvestment {
  [key: string]: any;
  stockType: string;
  stockInfo: string;
  stockLink?: string;
  unitsHeld: string;
  price: string;
  value: string;
  cost: string;
  gain: string;
  gainPercentage: string;
  details?: IInvestmentDetails;
  ticker: string;
}

interface IInvestmentDetails {
  [key: string]: any;
  sedol: string;
  transactions: ITransactions;
  lastDividend: string;
  nextDividend: string;
  firstDeal: string;
  lastDeal: string;
  totalDeals: string;
  holdingSummary?: IHoldingSummary;
}

interface IHoldingSummary {
  [key: string]: any;
  highestPricePaid: string;
  lowestPricePaid: string;
  weightedAvgPaid: string;
  highestPriceRecieved: string;
  lowestPriceRecieved: string;
  weightedAvgRecieved: string;
}

interface ITransactions {
  [key: string]: ITransaction;
}

interface ITransaction {
  date: string;
  type: string;
  reference: string;
  unitCost: number;
  quantity: number;
  cost: number;
}

logout()

If you are using hargreaves-lansdown in a continually running server environment, make sure you call logout() at the end of calling getInDepth(). This clears session cookies which ensures there are no weird authentication side-effects.

Future Updates

I am currently working on being able to query the accounts in more depth, right down to the individual holdings, and be able to programmatically buy and sell holdings.

If you enjoy using this package, consider buying me a coffee here ➡️ or in real life!