Skip to content

☁️ REST-ful API for fetching the Bitfinex Long vs Short ratio for BTC, ETH, LTC and XRP via Google Cloud Functions.

Notifications You must be signed in to change notification settings

joemccann/api-long-short-ratio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SYNOPSIS

☁️ REST-ful API for fetching the Bitfinex Long vs Short ratio for BTC, ETH, LTC and XRP via Google Cloud Functions.

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-long-short-ratio?asset=BTC

Or, if you prefer a POST:

curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio --data '{"asset": "BTC"}' -H "Content-Type: application/json"

The expected response:

{
  "data": {
    "long": 301751.81084729,
    "short": 146453.13477503,
    "timestamp": 1555083480000,
    "ratio": 2.0603984428931335,
    "date": "Fri Apr 12 2019 15:38:54 GMT+0000 (Coordinated Universal Time)"
  }
}

Or in the case there is a failure:

{
  "err": "Request failed: response body was null."
}

API

curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio?asset=BTC
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio?asset=ETH
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio?asset=LTC
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-long-short-ratio?asset=XRP

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-long-short-ratio --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

About

☁️ REST-ful API for fetching the Bitfinex Long vs Short ratio for BTC, ETH, LTC and XRP via Google Cloud Functions.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published