Nxt Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Latest Nxt Client 1.11.10 - NEW RELEASE: Ardor 2.0.5e TestNet - The Ignis ICO is over!! Ardor genesis snapshots will happen at Nxt block 1,630,000 (expected for 25th December)

Pages: [1] 2 3  All

Author Topic: questions about API - LAST PRICE, quantityQNT, and priceNQT  (Read 6416 times)

Damelon

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2307
    • View Profile
    • Nxt Inside
  • Karma: +792/-53

Quote
I am looking for the easiest & fastest possible way to acquire the LAST PRICE of nxt assets.
Do I really have to run my own node for that? Then it is something like this:
http://localhost:7876/nxt?requestType=getAsset&asset=15641806960898178066 --> decimals
http://localhost:7876/nxt?requestType=getTrades&asset=15641806960898178066 --> trades --> ...
Correct? Or is there a faster way?
Or:
Is there something like public data servers which provide me with such API answers - I really only want the last price.
And volume7d / volume24h / volume1h perhaps.
Thx a lot!

Can someone give me an answer to this question?
« Last Edit: March 21, 2015, 06:59:03 pm by Damelon »
Member of the Nxt Foundation | Donations: NXT-D6K7-MLY6-98FM-FLL5T
Join Nxt Slack! https://nxtchat.herokuapp.com/
Founder of Blockchain Workspace | Personal Site & Blog

achim

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 648
    • View Profile
  • Karma: +50/-6

He could use jones' public node:
http://jnxt.org:7876/nxt?requestType=getAsset&asset=15641806960898178066


Or if he wants more than just last price:
nxtportal.com is realtime: http://nxtportal.com/assets/15641806960898178066
NXT-7ML4-22U8-QNXK-22222

Tosch110

  • Ex-Staff Member
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2375
    • View Profile
  • Karma: +211/-18

yes, there is a faster way:

http://localhost:7876/nxt?requestType=getTrades&asset=15641806960898178066&firstIndex=0&lastIndex=1

This brings only the last trade, instead all of them. For calculating a 24h timespan etc, he would have to wait for 1.5e, the timestamp parameter is already included in the next version afaik.

No, he would not have to run his own node, but running an own node is the only way he would have control over his node and be sure that its online when he wants it to be online. Else he can get his network peers to connect to from here:

http://nxtpeers.com/index.php
http://www.peerexplorer.com/

Choosing one of the nodes the query would look like this for example:

http://scripterron.dyndns.biz:7876/nxt?requestType=getTrades&asset=15641806960898178066&firstIndex=0&lastIndex=1

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

You are great!

First of all, thanks the most for copying my FB question into this forum. The internet never ceases to amaze me - humans can be such wonderful creatures. Thanks.

And then thanks for your answers. Superb.


But I cannot ask my question here - because I am in newbie prison?

I would really like to ask my question, but the forum robot monster always says Sorry, you are not allowed to post external links.

Is there anything anyone can do about this? Thanks.
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

Damelon

  • Administrator
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2307
    • View Profile
    • Nxt Inside
  • Karma: +792/-53

You are great!

First of all, thanks the most for copying my FB question into this forum. The internet never ceases to amaze me - humans can be such wonderful creatures. Thanks.

And then thanks for your answers. Superb.


But I cannot ask my question here - because I am in newbie prison?

I would really like to ask my question, but the forum robot monster always says Sorry, you are not allowed to post external links.

Is there anything anyone can do about this? Thanks.

If you post your link but just format it like this hxxps://nxtforum.org/, it should at least show up.

Indeed, newbie prison. We get bots sometimes :)
Member of the Nxt Foundation | Donations: NXT-D6K7-MLY6-98FM-FLL5T
Join Nxt Slack! https://nxtchat.herokuapp.com/
Founder of Blockchain Workspace | Personal Site & Blog

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

Alright, I am doing my question step by step now, to persuade that rigid robot ...

Most important: My question is solved.
All is details now:
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

yes, there is a faster way:
lo calh ost :78 76 /n xt ? re questTy pe=g etTr ade s&a sse t=15 641806 960898178 066 &firstIndex=0&lastIndex=1
Great.
Thanks a lot for the firstIndex, lastIndex - that will speed up the whole thing a lot. I was fearing what to do if an asset has thousands of trades already, but your idea solves that. Great.

However, I still got two, so isn't it rather?
loc alho st:7 876/n xt? requestTy pe=getT rades&ass et=1564 180696089 8178066&firstIndex=0&lastIndex=0

AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

Or if he wants more than just last price:
nxtportal.com is realtime:  nxtportal.com /assets/15641806960898178066
Yes, first of all the price, and originally, I was looking for something exactly like nxtportal.com - but that site does not seem to have an API?


« Last Edit: March 10, 2015, 07:42:01 pm by altsheets »
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

My plan (correct me if I understood it wrong):

1) When my API request fails (because the last looked up server is offline now) ...

2) ... I ask   hxxp://nxtpeers.com/api/ to receive a new random node - will that node always have an open API?

if not, then I'd do it this way:

2) ... I ask   hxxp://peerexplorer.com/api_openapi_hallmark_version
("All nodes with open API, hallmark and latest version 1.4.16." peer explorer. com)  and take a random one.

Let's say 178.21.114.156

3) Then I put my question together, which is:
 hxxp://178.21.114.156:7876/nxt?requestType=getTrades&asset=15641806960898178066&firstIndex=0&lastIndex=0

and

4) digest the result.

Good plan?
« Last Edit: March 10, 2015, 07:46:21 pm by altsheets »
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

Open question:

The price is somehow hidden in
"priceNQT":"17100000000" - correct?

But what does that mean? ... 171 NXT per ASSET ?

It looks as if I don't even have to ask a second API question ("getAsset") to find out the decimals, because this same JSON answer now already contains
"decimals":0,


But why 0 ?

Hmmm ... I suppose decimals = 0 means that I always have to divide by 10^8 ?
So if it were decimals = 4, I would have to divide by 10^12 ?

So then the same thing would look like this?

"decimals":4,
"priceNQT":"171000000000000"


- correct understanding ?

« Last Edit: March 10, 2015, 07:44:10 pm by altsheets »
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

Tosch110

  • Ex-Staff Member
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2375
    • View Profile
  • Karma: +211/-18

Hello, you are on the right path with your nodes. Those are two possible scenarios, you could also save those peers into your own database and make regular checks for availability and speed of the nodes. This depends on the importance of your service being fast and reliable.
Best case is installing nxt on your host to make the calls on localhost.

http://nxtpeers.com/api/ will always have an open API and checked every minute. 
http://peerexplorer.com/api_openapi_hallmark_version yes, open API is checked and hallmarked is a good sign.

http://178.21.114.156:7876/nxt?requestType=getTrades&asset=15641806960898178066&firstIndex=0&lastIndex=0

Seems you are right, lastIndex also 0.

With the decimals it works as follows:

priceNQT is always the price of NXT * 100000000. NQT refers to NextQuant, which is 1 * 10^8 NXT
So for your example:
"priceNQT":"17100000000" = 171 NXT

The decimal is important for the amountQNT (QNT = Quantity). so you have the amountQNT = 1 / 10^decimals
"quantityQNT":"43" with 0 decimals = 43

Total NXT = (priceNQT * quantityQNT) / 100000000

This can be confusing at first because NQT and QNT look very similar.
« Last Edit: March 10, 2015, 10:33:19 pm by Tosch110 »

tiker

  • Jr. Member
  • **
  • Offline Offline
  • Posts: 26
    • View Profile
  • Karma: +1/-0

priceNQT is always the price of NXT / 100000000. NQT refers to NextQuant, which is 1/10^8 NXT
So for your example:
"priceNQT":"17100000000" = 171 NXT


Wouldn't priceNQT = (NXT * 100000000) if (priceNQT / 100000000) = NXT?

Tosch110

  • Ex-Staff Member
  • Hero Member
  • *****
  • Offline Offline
  • Posts: 2375
    • View Profile
  • Karma: +211/-18

priceNQT is always the price of NXT * 100000000. NQT refers to NextQuant, which is 1 * 10^8 NXT
So for your example:
"priceNQT":"17100000000" = 171 NXT


Wouldn't priceNQT = (NXT * 100000000) if (priceNQT / 100000000) = NXT?

yes, good catch! I have modified this

capodieci

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1333
  • Tips go to DeBuNe Dev fund
    • View Profile
    • DeBuNe - Decentralised Business Network
  • Karma: +256/-18

Quote
I am looking for the easiest & fastest possible way to acquire the LAST PRICE of nxt assets.
Do I really have to run my own node for that? Then it is something like this:
http://localhost:7876/nxt?requestType=getAsset&asset=15641806960898178066 --> decimals
http://localhost:7876/nxt?requestType=getTrades&asset=15641806960898178066 --> trades --> ...
Correct? Or is there a faster way?
Or:
Is there something like public data servers which provide me with such API answers - I really only want the last price.
And volume7d / volume24h / volume1h perhaps.
Thx a lot!

Can someone give me an answer to this question?

With DeBuNe we are working to provide public open API for all f those things (and more)!

At least one more month before it is avail tho :(

R
- Decentralised Business Network: DeBuNe -
Asset: 6926770479287491943 - Issuer: NXT-GQ27-DD53-YM6K-ER6HK
OTDocs.com - debune.org - nxtforum.org/debune - NEW: thesoundkey.com

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

Cool. Thanks again to everyone for clarifying this.

As you might suspect, I am planning to include asset prices into my software. But that will also take some time.

Anyone wants to already try it out now? 
For coins, it's already fully functional, supports 8 exchanges plus coinmarketcap,
and is polished, and really easy to use. Saves you time, and improves your trades.

This is my software: hxxp://bitcointalk.org/index.php?topic=978804
And this is the related asset: hxxp://bitcointalk.org/index.php?topic=981128

Happy about any help & opinions, and I will pay, of course, with extending your free serial validity.

AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

ThomasVeil

  • Hero Member
  • *****
  • Offline Offline
  • Posts: 1388
    • View Profile
  • Karma: +182/-11
NXT-BPV3-837M-QZTQ-9DQ69  oxpal.com

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

Linkified for the lazy.
Very nice to suppport me newbie.

Thanks a (10^8 / 100)

:-)
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

I CANNOT POST PYTHON CODE BECAUSE THE Sorry, you are not allowed to post external links. is programmed wrong. *MEH*

Later edit: removed the example code because: Hah, found the error in my thinking :-)
« Last Edit: March 15, 2015, 09:31:04 pm by altsheets »
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1
« Last Edit: March 15, 2015, 09:31:37 pm by altsheets »
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more

altsheets

  • Full Member
  • ***
  • Offline Offline
  • Posts: 232
  • check out #AAssetNXT #AltFolio and #AssetGraphs
    • View Profile
    • AssetGraphs-v2 live examples
  • Karma: +31/-1

ahhh *blink* lightbulb-above-my-head *g*

[...]
With the decimals it works as follows:

priceNQT is always the price of NXT * 100000000. NQT refers to NextQuant, which is 1 * 10^8 NXT
So for your example:
"priceNQT":"17100000000" = 171 NXT

The decimal is important for the amountQNT (QNT = Quantity). so you have the amountQNT = 1 / 10^decimals
"quantityQNT":"43" with 0 decimals = 43

Total NXT = (priceNQT * quantityQNT) / 100000000

ahhhh. So that would mean that ...

'decimals' is never relevant for the price ("priceNQT"),
but only for the amounts ("quantityQNT" in both ?requestType=getTrades and ?requestType=getAllAssets).

Correct? -->

pricePerAssetMeasuredInNxt = priceNQT / 100000000
numberOfTradedAssets = quantityQNT / 10^decimals




But shouldn't then your final formula be

Total NXT = (priceNQT * quantityQNT) / 100000000 / 10^decimals

so

Total NXT = (priceNQT * quantityQNT) /  10^ (decimals + 8 )

?

« Last Edit: March 15, 2015, 09:32:15 pm by altsheets »
AltFolio | Newbium DataSite | AAssetNXT & -HZ | AssetGraphs | ABEE | Advice | assetparser.py & shareholders.py | bamm.py | PeerCrawler | Github e.g. ChainCountDown, ethjsre | ... much more
Pages: [1] 2 3  All