Bitcoin Forum
June 17, 2024, 02:52:24 PM *
News: Latest Bitcoin Core release: 27.0 [Torrent]
 
   Home   Help Search Login Register More  
Pages: [1]
  Print  
Author Topic: Bitcoin price APIs  (Read 280 times)
sarannah (OP)
Member
**
Offline Offline

Activity: 103
Merit: 10


View Profile
November 10, 2017, 01:09:13 PM
 #1

Is there any API which returns just Poloniex Bitcoin price and nothing else.

Usually these return some thing like:

"Price: 7600.3"

I just need

7600

Or if string is for instance:

{"result":{"price":6710.1},"allowance":{"cost":300445910,"remaining":7699554090}}

How i can extract just price without decimals: 6710

Best would be some thing like this

return characters from 20 to 23 in string "{"result":{"price":6710.1},"allowance":{"cost":300445910,"remaining":7699554090}}"

This way i could use this code in other unix scripts too.
ettessuta
Newbie
*
Offline Offline

Activity: 35
Merit: 0


View Profile
November 10, 2017, 01:36:14 PM
 #2

i found some Apis like this ask user HCP will provide you with more information
fwman
Newbie
*
Offline Offline

Activity: 42
Merit: 0


View Profile
November 10, 2017, 06:14:19 PM
 #3

Why don't use Python language? If the price is returned in JSON format, you can easily use from Python.
olehgol260
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
November 10, 2017, 06:40:46 PM
 #4

What is a problem to parse the received JSON and round the price to the integer? In Go language it's really easy as you declare a struct with 1 field as Price and type float64 and after json.Unmarshal, you just cast it to int or use math library if you need.

What is the point to just get the integer and nothing else?
Rosscy
Member
**
Offline Offline

Activity: 243
Merit: 10


View Profile
November 10, 2017, 06:56:41 PM
 #5

i think some of this link will help
https://bitpay.com/bitcoin-payment-gateway-api
https://github.com/cryptoapi/Payment-Gateway
sarannah (OP)
Member
**
Offline Offline

Activity: 103
Merit: 10


View Profile
November 10, 2017, 07:24:57 PM
 #6

I don't know how to parse. :-)

Actually this code runs in Mac so it needs to be what ever Mac uses. API can return more than just price but then i need to parse it some how to integer.
olehgol260
Newbie
*
Offline Offline

Activity: 41
Merit: 0


View Profile
November 10, 2017, 10:23:49 PM
 #7

I don't know how to parse. :-)

Actually this code runs in Mac so it needs to be what ever Mac uses. API can return more than just price but then i need to parse it some how to integer.

what programming language do you use?
sarannah (OP)
Member
**
Offline Offline

Activity: 103
Merit: 10


View Profile
November 11, 2017, 05:13:51 AM
 #8

I don't know how to parse. :-)

Actually this code runs in Mac so it needs to be what ever Mac uses. API can return more than just price but then i need to parse it some how to integer.

what programming language do you use?

Bash? At least internets say that that is used in macOS Terminal app so i think it is Bash.

I can figure out rest of the script, only problem is parsing or finding API which returns just number.
Coding Enthusiast
Legendary
*
Offline Offline

Activity: 1039
Merit: 2783


Bitcoin and C♯ Enthusiast


View Profile WWW
November 11, 2017, 05:47:27 AM
 #9

Code:
curl -s 'https://poloniex.com/public?command=returnTicker' | python -c "import sys, json; print json.load(sys.stdin)['USDT_BTC']['last']"

Projects List+Suggestion box
Donate: 1Q9s or bc1q
|
|
|
FinderOuter(0.19.1)Ann-git
Denovo(0.7.0)Ann-git
Bitcoin.Net(0.26.0)Ann-git
|
|
|
BitcoinTransactionTool(0.11.0)Ann-git
WatchOnlyBitcoinWallet(3.2.1)Ann-git
SharpPusher(0.12.0)Ann-git
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!