GithubHelp home page GithubHelp logo

joemccann / api-charts Goto Github PK

View Code? Open in Web Editor NEW
0.0 2.0 0.0 85 KB

๐Ÿ“Š Opinionated, REST-ful API for fetching chart/candle data from a cryptocurrency exchange for an asset or set of assets.

JavaScript 100.00%
google cloud-function cloud-functions gcp-cloud-functions gcp

api-charts's Introduction

SYNOPSIS

๐Ÿ“Š Opinionated, REST-ful API for fetching chart/candle data from a cryptocurrency exchange for an asset or set of assets.

REQUIREMENTS

  1. A Google Cloud Account.
  2. Billing Enabled.
  3. API Access Enabled.
  4. gcloud CLI installed and in your $PATH.
  5. A preferred configuration created ( gcloud init ).

USAGE

curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-charts?exchange=binance&asset=btc-ltc&timeframe=1d

Or, if you prefer a POST:

curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-charts --data '{"exchange": "binance", "asset": "btc-ltc", "timeframe": "1d"}' -H "Content-Type: application/json"

The expected response:

{
  "data": [
    {
      "close": 6.399e-05,
      "high": 6.407e-05,
      "low": 6.387e-05,
      "open": 6.407e-05,
      "timestamp": 1555113600000,
      "volume": 14872
    },
    ...
  }
}

Or in the case there is a failure:

{
  "err": "Timeframe, 3h, not supported on Coinbase."
}

API

# One asset, on Binance, daily timeframe
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-charts?exchange=binance&asset=btc-ltc&timeframe=1d

# Three assets, on Binance, hourly timeframe; NOTE: response is an array of objects: {asset: XXX-YYYY, data: [{close, high, low, open, timestamp, volume}...]}
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-charts?assets=BTC-LTC,BTC-XRP,USDT-ZEC&exchange=Binance&timeframe=1h

# One asset, on Coinbase, hourly timeframe, with start date in Unix timstamp format in milliseconds
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-charts?asset=BTC-XRP&exchange=Coinbase&start=1555116991951000&timeframe=1h

# One asset, on Coinbase, hourly timeframe, with start and end dates in Unix timstamp format in milliseconds
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-charts?asset=BTC-XRP&exchange=Coinbase&start=1555116991951000&end=1555119991951000&timeframe=1h

DEPLOY

First, fork or clone this repo, then:

npm i

Now, deploy it GCP, run the following command in the root of this repository:

gcloud functions deploy api-charts --runtime nodejs10 --trigger-http --memory 128MB

You should receive a YAML like response in your terminal including the URL for the Cloud Function.

TESTS

npm i -D
npm test

AUTHORS

LICENSE

MIT

api-charts's People

Contributors

joemccann avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.