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

graphql-ccxt

v0.6.0

Published

wake up bears 🐻 ride bulls πŸ‚

Downloads

8

Readme

graphql-ccxt

wake up bears 🐻 ride bulls πŸ‚

You can read the graphql-ccxt GraphQL schema source here.

Features

  • Joins together GraphQL and CCXT: can fetch prices, read balance, open orders, etc. on multiple exchanges at once.
  • No dependencies other than graphql and ccxt (by the way, installed as peer deps).
  • It's isomorphic! It works on a server as usual (see demo below), but also in a browser (see examples/browser/ folder).
  • Last but not least, it can be used to increase your income πŸ’°πŸ’°πŸ’°

Credits

Tons of kudos to creators of GraphQL and CCXT. Coders that designed and implemented both projects are so smart and passionate, they are a great example of the power of open source.

Installation

Install this package and add the following peer dependencies:

  • graphql
  • ccxt

For instance with npm launch

npm install graphql ccxt graphql-ccxt

Demo

  1. Get this repository code.
  2. Install deps: npm install
  3. Launch the demo: npm start

Then point your browser to http://localhost:4000/graphql

query

Take a look to examples/graphql/ folder. It contains both queries and mutations, among others:

Access private API

Optionally, before launching the demo server, set the following environment variables accordingly:

  • BINANCE_APIKEY
  • BINANCE_APISECRET

Demo source code

The demo server is implemented by the following code.

const express = require('express')
const { graphqlHTTP } = require('express-graphql')
const { buildSchema } = require('graphql')
const {
  GraphqlCcxtContext,
  graphqlCcxtRoot,
  graphqlCcxtSchemaSource
} = require('graphql-ccxt')

async function startDemo() {
  // 1. Create GraphQL context. It holds your exchange clients.
  // //////////////////////////////////////////////////////////////////////////
  const context = new GraphqlCcxtContext()

  // Add a client on Binance exchange.
  // It will be private if environment variables are defined,
  // otherwise it will be public.
  await context.addClient({
    exchange: 'binance',
    apiKey: process.env.BINANCE_APIKEY,
    secret: process.env.BINANCE_APISECRET
  })

  // Add few public clients on other exchanges.
  await context.addClient({ exchange: 'coinbase' })
  await context.addClient({ exchange: 'bitfinex' })
  await context.addClient({ exchange: 'bittrex' })
  await context.addClient({ exchange: 'kraken' })
  await context.addClient({ exchange: 'binance', label: 'Public Binance' })

  // 2. Build GraphQL schema.
  // //////////////////////////////////////////////////////////////////////////
  const schema = buildSchema(graphqlCcxtSchemaSource)

  // 3. Launch express-graphql server.
  // //////////////////////////////////////////////////////////////////////////
  express()
    .use(
      '/graphql',
      graphqlHTTP({
        schema,
        rootValue: graphqlCcxtRoot,
        context,
        graphiql: {
          defaultQuery: '{ clients { exchange } }'
        }
      })
    )
    .listen(4000, () => {
      console.info(
        'Running a graphql-ccxt server at http://localhost:4000/graphql'
      )
    })
}

startDemo()

License

MIT