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

kraken-api-browser

v2.1.1

Published

kraken-api port for browsers

Downloads

32

Readme

kraken-api-browser

kraken-api-browser is a browser port of the server-side kraken API kraken-api.

Use npm i kraken-api-browser to install it.

It's a es6 module file, which means you can directly import it into your web page

<script type="module" src="/node_modules/kraken-api-browser/build.js"></script>

(see Browser Usage for more details)

You can also import it in a es6 module project, and in a TypeScript project (typings included)

import { KrakenClient } from 'kraken-api-browser';

Usage

const kraken = new KrakenClient();

async function main () {
  const { result } = await kraken.api('Ticker', { pair: 'XBTEUR' });

  console.log(result);
}

main()

Browser Usage

<script src="/node_modules/kraken-api-browser/build.js" type="module"></script>
<script>
  const kraken = new KrakenClient();
  ...
</script>

or

<script type="module">
  import { KrakenClient } from '/node_modules/kraken-api-browser/build.js';

  const kraken = new KrakenClient();
  ...
</script>

(note: if you are using a server that resolves es module paths on requests you know what's up)

TypeScript Usage

If you are using TypeScript you can easily see the methods available with auto-suggestion feature in your IDE.

Availabe public methods

'Time' | 'Assets' | 'AssetPairs' | 'Ticker' | 'Depth' | 'Trades' | 'Spread' | 'OHLC'

(note: You can also use the publicMethod function to narrow down the list of available public methods because right now the private methods won't work, read the disclaimer below)

Disclaimer

I contacted the Kraken support to ask them to allow cors requests when using private methods such as Balance but they couldn't help me... When requesting a private method Kraken API requires a bunch of security codes such as the API keys and other things to be sent in the header of that https request. On a server side it works just fine but browsers such as Google Chrome send a pre-flight OPTIONS request before the POST one (https://stackoverflow.com/a/29954326/773595) when modifying the header of sensitive requests.
For this reason the private methods in this framework are for the time being not working
One way for Kraken to fix this issue would be to accept OPTIONS requests from trusted origins (if not all origins) but they didn't.

Support

Buy Me a Coffee
bitcoin address: 3KfrLBhWgKxnNH9hoC8ipSPYi3LW3Qrj8i