/ledger-getquote-blocktap

An implementation of ledger getquote that uses Blocktap.io GraphQL to retrieve pricing data

Primary LanguageShellMIT LicenseMIT

ledger-getquote-blocktap

License: MIT Linux and macOS build Status Windows build status

An implementation of ledger-cli getquote that uses Blocktap.io GraphQL to retrieve cryptoasset pricing data.

Usage

getquote-blocktap <asset symbol>

Example:

$ getquote-blocktap BTC
3680.000000000

Installation

Homebrew is the preferred installation method:

brew tap colindean/ledger-getquote-blocktap https://github.com/colindean/ledger-getquote-blocktap.git
brew install ledger-getquote-blocktap-bin

Alternatively, download the latest release here.

For Windows, you can use the MSVC version if you already have the 2015 Visual C++ Runtime already installed. Otherwise, try the GNU version.

Releasing

This repo is configured to release on annotated tags on push.

cargo release --dry-run
# once satisfied
cargo release

Communicating with Blocktap.io

The base GraphQL

Run this in Blocktap's playground:

query ledger_pricedb {
  assets(sort: { marketCapRank: ASC }){ # need to programatically add filters here for the asset passed into getquote.
    assetName
    assetSymbol
    markets(aggregation: VWA, filter: { quoteSymbol_eq: "USD" }) {
      ticker {
        lastPrice
      }
    }
  }
}

Retrieve Blocktap's JSON schema

Use the fantastic graphql-rust project's client tool:

cargo install graphql_client_cli

Get the latest version of the JSON schema:

graphql-client introspect-schema https://api.blocktap.io/graphql --output /tmp/blocktap.json