GithubHelp home page GithubHelp logo

rxcod9 / bitcurl Goto Github PK

View Code? Open in Web Editor NEW
0.0 0.0 4.0 6 KB

Useful Curl Commands to call top exchanges apis and printing response in pretty json or table format

cryptocurrency curl bittrex bittrex-api poloniex binance api bitcurl

bitcurl's Introduction

BitCurl

Some useful curl commands for top crypto exchanges.

BITTREX



PUBLIC API



Get Markets

Used to get the open and available trading markets at Bittrex along with other meta data.

basic command

curl -s "https://bittrex.com/api/v1.1/public/getmarkets"

with pretty json response

curl -s "https://bittrex.com/api/v1.1/public/getmarkets" | jq -r

Table format output

curl -s "https://bittrex.com/api/v1.1/public/getmarkets" | \
jq -r ' ["MarketCurrency","BaseCurrency", "MarketCurrencyLong", "BaseCurrencyLong", "MinTradeSize", "MarketName", "IsActive", "Created", "IsSponsored", "Notice"], (.result[] | [.MarketCurrency, .BaseCurrency, .MarketCurrencyLong, .BaseCurrencyLong, .MinTradeSize, .MarketName, .IsActive, .Created, .IsSponsored, .Notice]) | @tsv' | \
awk -F '\t' '{print $1 "\t" $2 "\t" $3 "\t" $4 "\t" ($5=="MinTradeSize" ? $5 : sprintf("%.8f",$5)) "\t" $6 "\t" ($7=="" ? "NA" : $7) "\t" $8 "\t" ($9=="" ? "NA" : $9) "\t" ($10=="" ? "NA" : $10) "\t"}' | \
column -t -s $'\t'

Table format output one liner

curl -s "https://bittrex.com/api/v1.1/public/getmarkets" | jq -r ' ["MarketCurrency","BaseCurrency", "MarketCurrencyLong", "BaseCurrencyLong", "MinTradeSize", "MarketName", "IsActive", "Created", "IsSponsored", "Notice"], (.result[] | [.MarketCurrency, .BaseCurrency, .MarketCurrencyLong, .BaseCurrencyLong, .MinTradeSize, .MarketName, .IsActive, .Created, .IsSponsored, .Notice]) | @tsv' | awk -F '\t' '{print $1 "\t" $2 "\t" $3 "\t" $4 "\t" ($5=="MinTradeSize" ? $5 : sprintf("%.8f",$5)) "\t" $6 "\t" ($7=="" ? "NA" : $7) "\t" $8 "\t" ($9=="" ? "NA" : $9) "\t" ($10=="" ? "NA" : $10) "\t"}' | column -t -s $'\t'

Get Currencies

Used to get all supported currencies at Bittrex along with other meta data.

basic command

curl -s "https://bittrex.com/api/v1.1/public/getcurrencies"

with pretty json response

curl -s "https://bittrex.com/api/v1.1/public/getcurrencies" | jq -r

Table format output

curl -s "https://bittrex.com/api/v1.1/public/getcurrencies" | \
jq -r ' ["Currency", "CurrencyLong", "MinConfirmation", "TxFee", "IsActive", "CoinType", "Notice", "BaseAddress"], (.result[] | [.Currency, .CurrencyLong, .MinConfirmation, .TxFee, .IsActive, .CoinType, .Notice, .BaseAddress]) | @tsv' | \
awk -F '\t' '{print $1 "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t" ($7=="" ? "NA" : $7) "\t" ($8=="" ? "NA" : $8)}' | \
column -t -s $'\t'

Table format output one liner

curl -s "https://bittrex.com/api/v1.1/public/getcurrencies" | jq -r ' ["Currency", "CurrencyLong", "MinConfirmation", "TxFee", "IsActive", "CoinType", "Notice", "BaseAddress"], (.result[] | [.Currency, .CurrencyLong, .MinConfirmation, .TxFee, .IsActive, .CoinType, .Notice, .BaseAddress]) | @tsv' | awk -F '\t' '{print $1 "\t" $2 "\t" $3 "\t" $4 "\t" $5 "\t" $6 "\t" ($7=="" ? "NA" : $7) "\t" ($8=="" ? "NA" : $8)}' | column -t -s $'\t'

Get Ticker

Used to get the current tick values for a market.

basic command

curl -s "https://bittrex.com/api/v1.1/public/getticker?market=BTC-DGB"

with pretty json response

curl -s "https://bittrex.com/api/v1.1/public/getticker?market=BTC-DGB" | jq -r

Table format output

curl -s "https://bittrex.com/api/v1.1/public/getticker?market=BTC-DGB" | \
jq -r ' ["Bid", "Ask", "Last"], (.result | [.Bid, .Ask, .Last]) | @tsv' | \
awk -F '\t' '{print ($1=="Bid" ? $1 : sprintf("%.8f",$1)) "\t" ($2=="Ask" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Last" ? $3 : sprintf("%.8f",$3))}' | \
column -t -s $'\t'

Table format output one liner

curl -s "https://bittrex.com/api/v1.1/public/getticker?market=BTC-DGB" | jq -r ' ["Bid", "Ask", "Last"], (.result | [.Bid, .Ask, .Last]) | @tsv' | awk -F '\t' '{print ($1=="Bid" ? $1 : sprintf("%.8f",$1)) "\t" ($2=="Ask" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Last" ? $3 : sprintf("%.8f",$3))}' | column -t -s $'\t'

Get Market Summaries

Used to get the last 24 hour summary of all active markets.

basic command

curl -s "https://bittrex.com/api/v1.1/public/getmarketsummaries"

with pretty json response

curl -s "https://bittrex.com/api/v1.1/public/getmarketsummaries" | jq -r

Table format output

curl -s "https://bittrex.com/api/v1.1/public/getmarketsummaries" | \
jq -r ' 
["MarketName", "High", "Low", "Volume", "Last", "BaseVolume", "TimeStamp", "Bid", "Ask", "OpenBuyOrders", "OpenSellOrders", "PrevDay", "Created", "DisplayMarketName"], (.result[] | 
[.MarketName, .High, .Low, .Volume, .Last, .BaseVolume, .TimeStamp, .Bid, .Ask, .OpenBuyOrders, .OpenSellOrders, .PrevDay, .Created, .DisplayMarketName]) | @tsv' | \
awk -F '\t' '{print $1 "\t" ($2=="High" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Low" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Volume" ? $4 : sprintf("%.8f",$4)) "\t" ($5=="Last" ? $5 : sprintf("%.8f",$5)) "\t" ($6=="BaseVolume" ? $2 : sprintf("%.8f",$2)) "\t" $7 "\t" ($8=="Bid" ? $8 : sprintf("%.8f",$8)) "\t" ($9=="Ask" ? $9 : sprintf("%.8f",$9)) "\t" $10 "\t" $11 "\t" ($12=="PrevDay" ? $12 : sprintf("%.8f",$12)) "\t" $13 "\t" $14 "\t" }' | \
column -t -s $'\t'

Table format output one liner

curl -s "https://bittrex.com/api/v1.1/public/getmarketsummaries" | jq -r '["MarketName", "High", "Low", "Volume", "Last", "BaseVolume", "TimeStamp", "Bid", "Ask", "OpenBuyOrders", "OpenSellOrders", "PrevDay", "Created", "DisplayMarketName"], (.result[] | [.MarketName, .High, .Low, .Volume, .Last, .BaseVolume, .TimeStamp, .Bid, .Ask, .OpenBuyOrders, .OpenSellOrders, .PrevDay, .Created, .DisplayMarketName]) | @tsv' | awk -F '\t' '{print $1 "\t" ($2=="High" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Low" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Volume" ? $4 : sprintf("%.8f",$4)) "\t" ($5=="Last" ? $5 : sprintf("%.8f",$5)) "\t" ($6=="BaseVolume" ? $2 : sprintf("%.8f",$2)) "\t" $7 "\t" ($8=="Bid" ? $8 : sprintf("%.8f",$8)) "\t" ($9=="Ask" ? $9 : sprintf("%.8f",$9)) "\t" $10 "\t" $11 "\t" ($12=="PrevDay" ? $12 : sprintf("%.8f",$12)) "\t" $13 "\t" $14 "\t" }' | column -t -s $'\t'

Get Market Summary

Used to get the last 24 hour summary of a specific market.

basic command

curl -s "https://bittrex.com/api/v1.1/public/getmarketsummary?market=BTC-DGB"

with pretty json response

curl -s "https://bittrex.com/api/v1.1/public/getmarketsummary?market=BTC-DGB" | jq -r

Table format output

curl -s "https://bittrex.com/api/v1.1/public/getmarketsummary?market=BTC-DGB" | \
jq -r ' 
["MarketName", "High", "Low", "Volume", "Last", "BaseVolume", "TimeStamp", "Bid", "Ask", "OpenBuyOrders", "OpenSellOrders", "PrevDay", "Created", "DisplayMarketName"], (.result[] | 
[.MarketName, .High, .Low, .Volume, .Last, .BaseVolume, .TimeStamp, .Bid, .Ask, .OpenBuyOrders, .OpenSellOrders, .PrevDay, .Created, .DisplayMarketName]) | @tsv' | \
awk -F '\t' '{print $1 "\t" ($2=="High" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Low" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Volume" ? $4 : sprintf("%.8f",$4)) "\t" ($5=="Last" ? $5 : sprintf("%.8f",$5)) "\t" ($6=="BaseVolume" ? $2 : sprintf("%.8f",$2)) "\t" $7 "\t" ($8=="Bid" ? $8 : sprintf("%.8f",$8)) "\t" ($9=="Ask" ? $9 : sprintf("%.8f",$9)) "\t" $10 "\t" $11 "\t" ($12=="PrevDay" ? $12 : sprintf("%.8f",$12)) "\t" $13 "\t" $14 "\t" }' | \
column -t -s $'\t'

Table format output one liner

curl -s "https://bittrex.com/api/v1.1/public/getmarketsummary?market=BTC-DGB" | jq -r '["MarketName", "High", "Low", "Volume", "Last", "BaseVolume", "TimeStamp", "Bid", "Ask", "OpenBuyOrders", "OpenSellOrders", "PrevDay", "Created", "DisplayMarketName"], (.result[] | [.MarketName, .High, .Low, .Volume, .Last, .BaseVolume, .TimeStamp, .Bid, .Ask, .OpenBuyOrders, .OpenSellOrders, .PrevDay, .Created, .DisplayMarketName]) | @tsv' | awk -F '\t' '{print $1 "\t" ($2=="High" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Low" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Volume" ? $4 : sprintf("%.8f",$4)) "\t" ($5=="Last" ? $5 : sprintf("%.8f",$5)) "\t" ($6=="BaseVolume" ? $2 : sprintf("%.8f",$2)) "\t" $7 "\t" ($8=="Bid" ? $8 : sprintf("%.8f",$8)) "\t" ($9=="Ask" ? $9 : sprintf("%.8f",$9)) "\t" $10 "\t" $11 "\t" ($12=="PrevDay" ? $12 : sprintf("%.8f",$12)) "\t" $13 "\t" $14 "\t" }' | column -t -s $'\t'

Get Order book

Used to get retrieve the orderbook for a given market.

basic command

curl -s "https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-DGB&type=both"

with pretty json response

curl -s "https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-DGB&type=both" | jq -r

Table format output

curl -s "https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-DGB&type=both" | \
jq -r ' 
["Type", "Quantity", "Rate"], (.result | 
keys[] as $k | (.[$k][] | [$k, .Quantity, .Rate])) | @tsv' | \
awk -F '\t' '{print $1 "\t" ($2=="Quantity" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Rate" ? $3 : sprintf("%.8f",$3)) }' | \
column -t -s $'\t'

Table format output one liner

curl -s "https://bittrex.com/api/v1.1/public/getorderbook?market=BTC-DGB&type=both" | jq -r '["Type", "Quantity", "Rate"], (.result | keys[] as $k | (.[$k][] | [$k, .Quantity, .Rate])) | @tsv' | awk -F '\t' '{print $1 "\t" ($2=="Quantity" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Rate" ? $3 : sprintf("%.8f",$3)) }' | column -t -s $'\t'

Get Market History

Used to get the last 24 hour summary of a specific market.

basic command

curl -s "https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-DGB"

with pretty json response

curl -s "https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-DGB" | jq -r

Table format output

curl -s "https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-DGB" | \
jq -r ' 
["Id", "TimeStamp", "Quantity", "Price", "Total", "FillType", "OrderType"], (.result[] | 
[.Id, .TimeStamp, .Quantity, .Price, .Total, .FillType, .OrderType]) | @tsv' | \
awk -F '\t' '{print $1 "\t" $2 "\t" ($3=="Quantity" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Price" ? $4 : sprintf("%.8f",$4)) "\t" ($5=="Total" ? $5 : sprintf("%.8f",$5)) "\t" $6 "\t" $7 "\t" }' | \
column -t -s $'\t'

Table format output one liner

curl -s "https://bittrex.com/api/v1.1/public/getmarkethistory?market=BTC-DGB" | jq -r '["Id", "TimeStamp", "Quantity", "Price", "Total", "FillType", "OrderType"], (.result[] | [.Id, .TimeStamp, .Quantity, .Price, .Total, .FillType, .OrderType]) | @tsv' | awk -F '\t' '{print $1 "\t" $2 "\t" ($3=="Quantity" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Price" ? $4 : sprintf("%.8f",$4)) "\t" ($5=="Total" ? $5 : sprintf("%.8f",$5)) "\t" $6 "\t" $7 "\t" }' | column -t -s $'\t'


MARKET API



EXPORT API KEYS FIRST

export BITTREX_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
export BITTREX_API_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxx

TODO



ACCOUNT API



EXPORT API KEYS FIRST

export BITTREX_API_KEY=xxxxxxxxxxxxxxxxxxxxxxxxxxxx
export BITTREX_API_SECRET=xxxxxxxxxxxxxxxxxxxxxxxxxxxx

Get Balances

Used to retrieve all balances from your account.

basic command

NONCE=$(date +%s)
URL="https://bittrex.com/api/v1.1/account/getbalances?apikey=$BITTREX_API_KEY&nonce=$NONCE"
API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET)
curl -H "apisign: $API_SIGN" -s $URL

basic command one liner

NONCE=$(date +%s) && URL="https://bittrex.com/api/v1.1/account/getbalances?apikey=$BITTREX_API_KEY&nonce=$NONCE" && API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET) && curl -H "apisign: $API_SIGN" -s $URL

with pretty json response

NONCE=$(date +%s)
URL="https://bittrex.com/api/v1.1/account/getbalances?apikey=$BITTREX_API_KEY&nonce=$NONCE"
API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET)
curl -H "apisign: $API_SIGN" -s $URL | jq -r

with pretty json response one liner

NONCE=$(date +%s) && URL="https://bittrex.com/api/v1.1/account/getbalances?apikey=$BITTREX_API_KEY&nonce=$NONCE" && API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET) && curl -H "apisign: $API_SIGN" -s $URL | jq -r

Table format output

NONCE=$(date +%s)
URL="https://bittrex.com/api/v1.1/account/getbalances?apikey=$BITTREX_API_KEY&nonce=$NONCE"
API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET)
curl -H "apisign: $API_SIGN" \
-s $URL | \
jq -r ' ["Currency", "Balance", "Available", "Pending", "CryptoAddress"], (.result[] | select(.Balance > 0) | [.Currency, .Balance, .Available, .Pending, .CryptoAddress]) | @tsv' | \
awk -F '\t' '{print $1 "\t" ($2=="Balance" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Available" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Pending" ? $4 : sprintf("%.8f",$4)) "\t" $5}' | \
column -t -s $'\t'

Table format output one liner

NONCE=$(date +%s) && URL="https://bittrex.com/api/v1.1/account/getbalances?apikey=$BITTREX_API_KEY&nonce=$NONCE" && API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET) && curl -H "apisign: $API_SIGN" -s $URL | jq -r ' ["Currency", "Balance", "Available", "Pending", "CryptoAddress"], (.result[] | select(.Balance > 0) | [.Currency, .Balance, .Available, .Pending, .CryptoAddress]) | @tsv' | awk -F '\t' '{print $1 "\t" ($2=="Balance" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Available" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Pending" ? $4 : sprintf("%.8f",$4)) "\t" $5}' | column -t -s $'\t'

Get Balance

Used to retrieve the balance from your account for a specific currency.

basic command

NONCE=$(date +%s)
URL="https://bittrex.com/api/v1.1/account/getbalance?apikey=$BITTREX_API_KEY&nonce=$NONCE&currency=DGB"
API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET)
curl -H "apisign: $API_SIGN" -s $URL

basic command one liner

NONCE=$(date +%s) && URL="https://bittrex.com/api/v1.1/account/getbalance?apikey=$BITTREX_API_KEY&nonce=$NONCE&currency=DGB" && API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET) && curl -H "apisign: $API_SIGN" -s $URL

with pretty json response

NONCE=$(date +%s)
URL="https://bittrex.com/api/v1.1/account/getbalance?apikey=$BITTREX_API_KEY&nonce=$NONCE&currency=DGB"
API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET)
curl -H "apisign: $API_SIGN" -s $URL | jq -r

with pretty json response one liner

NONCE=$(date +%s) && URL="https://bittrex.com/api/v1.1/account/getbalance?apikey=$BITTREX_API_KEY&nonce=$NONCE&currency=DGB" && API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET) && curl -H "apisign: $API_SIGN" -s $URL | jq -r

Table format output

NONCE=$(date +%s)
URL="https://bittrex.com/api/v1.1/account/getbalance?apikey=$BITTREX_API_KEY&nonce=$NONCE&currency=DGB"
API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET)
curl -H "apisign: $API_SIGN" \
-s $URL | \
jq -r ' ["Currency", "Balance", "Available", "Pending", "CryptoAddress", "Requested", "Uuid"], (.result | [.Currency, .Balance, .Available, .Pending, .CryptoAddress, .Requested, .Uuid]) | @tsv' | \
awk -F '\t' '{print $1 "\t" ($2=="Balance" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Available" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Pending" ? $4 : sprintf("%.8f",$4)) "\t" $5 "\t" $6 "\t" $7}' | \
column -t -s $'\t'

Table format output one liner

NONCE=$(date +%s) && URL="https://bittrex.com/api/v1.1/account/getbalance?apikey=$BITTREX_API_KEY&nonce=$NONCE&currency=DGB" && API_SIGN=$(echo -n $URL | openssl sha512 -hmac $BITTREX_API_SECRET) && curl -H "apisign: $API_SIGN" -s $URL | jq -r ' ["Currency", "Balance", "Available", "Pending", "CryptoAddress", "Requested", "Uuid"], (.result | [.Currency, .Balance, .Available, .Pending, .CryptoAddress, .Requested, .Uuid]) | @tsv' | awk -F '\t' '{print $1 "\t" ($2=="Balance" ? $2 : sprintf("%.8f",$2)) "\t" ($3=="Available" ? $3 : sprintf("%.8f",$3)) "\t" ($4=="Pending" ? $4 : sprintf("%.8f",$4)) "\t" $5 "\t" $6 "\t" $7}' | column -t -s $'\t'

@TODO ADD MISSING BITTREX APIS commands ADD POLONIX API commands ADD BINANCE API commands

bitcurl's People

Contributors

krishhna13 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.