π An opinionated, standardized approach to obtaining assets from any cryptocurrency exchange from one REST-ful API.
- A Google Cloud Account.
- Billing Enabled.
- API Access Enabled.
gcloud
CLI installed and in your$PATH
.- A preferred configuration created (
gcloud init
).
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-assets?exchange=Binance
Or, if you prefer a POST
:
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-assets --data '{"exchange": "Binance"}' -H "Content-Type: application/json"
The expected response:
{
"data":
[
{
"base": 'ETH',
"original": 'ETHBTC',
"pair": 'BTC-ETH',
"quote": 'BTC'
},
...
]
}
Or in the case there is a failure:
{
"err": "Exchange, XXX, is not supported."
}
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-assets?exchange=Binance
curl https://${DEFAULT_REGION}-${PROJECT}.cloudfunctions.net/api-assets?exchange=Coinbase
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-assets --runtime nodejs10 --trigger-http --memory 128MB
You should receive a YAML like response in your terminal including the URL for the Cloud Function.
In the cryptocurrency space, there are little to no standards for APIs or nomenclature. Each exchange supports a different set of assets and the naming conventions are different across exchanges.
For example, Binance's API returns an asset pair like this:
'ZRXUSDT'
And Coinbase's API returns an asset pair like this:
'ZRX-USD'
api-assets
is opinionated and returns a JSON object in the format of:
{
base,
original,
pair,
quote
}
So when you query api-assets
for Binance you receive the following:
{ base: 'ZRX',
original: 'ZRXUSDT',
pair: 'USDT-ZRX',
quote: 'USDT' }
So when you query api-assets
for Coinbase you receive the following:
{ base: 'ZRX',
original: 'ZRX-USD',
pair: 'USD-ZRX',
quote: 'USD' }
The goal here is to have consistency across the name of asset pairs. I've chosen quote-base
where base
is the asset you are looking to buy or sell (e.g. ZRX) and quote
is the asset that the base
is being quoted or priced in.
If you want to buy 10 ZRX tokens in USD you would be looking for the asset pair USD-ZRX
.
- β Binance
- β Coinbase
Pull requests accepted by following the pattern in the
index.js
and passing tests in thetest.js
file.
npm i -D
npm test
MIT