Bitcoin Forum

Bitcoin => Pools => Topic started by: Inaba on May 22, 2012, 08:10:41 PM



Title: Pool API Standard
Post by: Inaba on May 22, 2012, 08:10:41 PM
SMF won't format tables properly (surprise!) ... I will reformat it if it's too confusing.

Here is a first draft proposal for a JSON API standards for Bitcoin Pools:

Generic keys:
JSON KeyDescription
versionVersion of the API in use

Pool keys:
JSON KeyDescription
round_durationDuration of the current round
round_sharesNumber of shares submitted in current round
hashrateTotal hashrate of the pool


User keys:
JSON KeyDescription
round_shares
Total shares submitted by user for current round
estimated_reward
Estimated reward the user will receive on next payout in BTC
hashrateTotal hashrate of the user
last_activity
Last miner activity in GMT
btc_balanceCurrent available balance for the user in BTC
btc_unconfirmedUnconfirmed/unavailable balance for the user in BTC
btc_paidTotal amount paid to the user in BTC
last_payout_amountLast amount paid to the user in BTC
last_payout_timeTime user was paid in GTM


Title: Re: Pool API Standard
Post by: flower1024 on May 22, 2012, 08:21:49 PM
what do you think about adding a field about the payout-method used?
and i would love to see standardized uris too.


Title: Re: Pool API Standard
Post by: Inaba on May 22, 2012, 08:26:41 PM
Uris? 

What do you mean by payout method exactly?


Title: Re: Pool API Standard
Post by: Clipse on May 22, 2012, 08:31:03 PM
I really like these suggestions, I will soon be adding proper json and may aswell make use of the suggested options once "finalised" in this thread I assume.


Title: Re: Pool API Standard
Post by: DeathAndTaxes on May 22, 2012, 08:31:17 PM
I assume he mean reward method (PPS, SMPSS, DGM, etc)?

Including things like fee %, payout tx fees, merge mining would make it possible to keep something like this actually up to date. :)
https://en.bitcoin.it/wiki/Comparison_of_mining_pools


Title: Re: Pool API Standard
Post by: flower1024 on May 22, 2012, 08:32:50 PM
I assume he mean reward method (PPS, SMPSS, DGM, etc)?

yes, thanks
would be easy to develop an app to monitor multiple pools then


Title: Re: Pool API Standard
Post by: Luke-Jr on May 22, 2012, 08:42:21 PM
https://en.bitcoin.it/wiki/BIP_PoolAPI WIP


Title: Re: Pool API Standard
Post by: P_Shep on May 22, 2012, 09:31:57 PM
p_shep approves this message :)


Title: Re: Pool API Standard
Post by: organofcorti on May 22, 2012, 09:36:56 PM
A standardised api for pool stat history would be nice.


Title: Re: Pool API Standard
Post by: P_Shep on May 22, 2012, 10:00:19 PM
https://en.bitcoin.it/wiki/BIP_PoolAPI WIP

"rewardalgo" may have to go per worker. Some pools you can select what worker does what... EMC & Ozcoin allows this. Perhaps this field can be used to list available algorithms.
I quite liked my idea for a round/block structure. Allows for block history to use the same structure repeated. And everyone likes re-using code :)


Title: Re: Pool API Standard
Post by: organofcorti on May 22, 2012, 10:40:58 PM
For a pool history API, for pools like deepbit where pool history will be thousands of blocks there might need to be a protocol limiting the number of blocks to 100 recent blocks, and then have a slightly different url for blocks further back.

I'd like to see a JSON or other API present a pool history table like this:

Code:
Block height/hash | Block timestamp | Round duration | Total submitted shares | Current difficulty | <Payout method specific field>
Data should be standardised too. 'Round duration' should be in seconds and the timestamp should be in the standard unix  %Y-%m-%d %H:%M:%S. Current difficulty is important to include. It's easily available elsewhere, but this being a block history API it's a pain for a miner to search the difficulty history for each and every block.

The field for <Payout method specific field> can be used for any results specific to a payout method. I had SMPPS in mind (a field for buffer), but I'm sure other payout methods would find a use for it.


Title: Re: Pool API Standard
Post by: Graet on May 22, 2012, 11:54:35 PM
A standardised api for pool stat history would be nice.
standardisation is slowly creeping into bitcoin - which is good

Ozcoin shows per worker hashrate as well as total, this was on user request - I think it needs to be included for people that use API to monitor rigs up/down. e.g. our desktop widget will not work without separated worker hashrates.
At Ozcoin payout method is by user not worker (this might change in the future)
Currently we are doing some heavy development on the backend and site - whilst a great idea a standardised API is not high on our priorities.




Title: Re: Pool API Standard
Post by: DeathAndTaxes on May 23, 2012, 12:58:06 AM
Data should be standardised too.

Agree

Quote
'Round duration' should be in seconds

Agreed (as in integer unformated # of seconds)

Quote
and the timestamp should be in the standard unix  %Y-%m-%d %H:%M:%S.
In my opinon formatting has no place in an API that is a presentation layer task.  Unix/Posix time is better since it is an integer and every language has tools to format it.

For example as of writing Unix/Posix time is 1337632227

Still the larger point is that data format should be part of the spec.

Quote
Current difficulty is important to include.
Agreed.


Title: Re: Pool API Standard
Post by: organofcorti on May 23, 2012, 01:14:43 AM
and the timestamp should be in the standard unix  %Y-%m-%d %H:%M:%S.
In my opinon formatting has no place in an API that is a presentation layer task.  Unix/Posix time is better since it is an integer and every language has tools to format it.

For example as of writing Unix/Posix time is 1337632227
I would definitely prefer it to be unixtime for my own purposes, although I get a seamless conversion when I need it. However I proposed the above format because I thought that the average miner might not be able to use unixtime so easily.
Quote
Still the larger point is that data format should be part of the spec.
Yes, that's the main thing. Anyone wanting to - for example - create a website to list miner api results or pool history will need all data standardised if she or he's going to list all pools equally easily. Btc-poolwatch.com was a constant job for koo (the owner/writer) since adding an api meant writing a new code to interpret the api, and any api changes broke the service.


Title: Re: Pool API Standard
Post by: Inaba on May 23, 2012, 02:19:24 AM
I think UNIX timestamp is the way to go.  If a pool wants to add extra "human" time, then that's easily done.  I think the standard as UNIX time is the right choice.  Really, all time should be given in unix time stamps and extra fields added for human time if desired.

So my proposal for the standard:

All time displays presented as UNIX epoc.  This will also do away with the need for timezoning questions/issues.
All hash rates presented as hashes per second.
All BTC's presented as Satoshis




Title: Re: Pool API Standard
Post by: P_Shep on May 23, 2012, 03:29:11 AM
I think UNIX timestamp is the way to go.  If a pool wants to add extra "human" time, then that's easily done.  I think the standard as UNIX time is the right choice.  Really, all time should be given in unix time stamps and extra fields added for human time if desired.

So my proposal for the standard:

All time displays presented as UNIX epoc.  This will also do away with the need for timezoning questions/issues.
All hash rates presented as hashes per second.
All BTC's presented as Satoshis

Sounds good to me


Title: Re: Pool API Standard
Post by: organofcorti on May 23, 2012, 06:14:07 AM
I think UNIX timestamp is the way to go.  If a pool wants to add extra "human" time, then that's easily done.  I think the standard as UNIX time is the right choice.  Really, all time should be given in unix time stamps and extra fields added for human time if desired.

So my proposal for the standard:

All time displays presented as UNIX epoc.  This will also do away with the need for timezoning questions/issues.
All hash rates presented as hashes per second.
All BTC's presented as Satoshis


Good proposal Inaba, and thanks to Inaba and P_Shep for getting this going.

Can I add:
  • All fields to be integer (no char, no added commas etc, no double)
  • Apis should all be the same format (preferably JSON).
  • The number and order of fields in each api should be standardised.
  • The api call should be standardised -
    eg the following could call worker stats:
Code:
poolname.com/api/workername

  • Any api call that includes historical data should include an option for selection of amount of data. Eg if X is the last X rounds of historical data:[\li]
    Code:
    poolname.com/api/username/history?X



Title: Re: Pool API Standard
Post by: organofcorti on May 23, 2012, 07:34:55 AM
One more thing - a pool history request shouldn't require a key (Ahem maxbtc, I'm looking at you :))


Title: Re: Pool API Standard
Post by: slush on May 23, 2012, 09:48:44 AM
estimated_reward
Estimated reward the user will receive on next payout in BTC
What if user (or few of his workers) are PPS? null value?

Quote
last_activity
Last miner activity in GMT

UTC, not GMT! GMT has summer/winter time, which is always pain in applications.

Quote
btc_balanceCurrent available balance for the user in BTC
btc_unconfirmedUnconfirmed/unavailable balance for the user in BTC
btc_paidTotal amount paid to the user in BTC

Let's rename it to balance, balance_unconfirmed, balance_paid. Otherwise we'll rename those fields for NMC? :-)



Title: Re: Pool API Standard
Post by: slush on May 23, 2012, 09:54:21 AM
I'm not against this initiative if it will need just to rename columns and URLs in my own API (which was - as Tycho mentioned - the first API, and there's no general issue with that). That means - I don't see any reason to change token management etc.

Also, we should define some standard on ask rate from clients. I'm caching API calls for 30 seconds, but still I see some stupid users fetching JSON data every second. That's not only annoying, that also needs much more transfers than mining itself of those users (especially when they're CPU miners).


Title: Re: Pool API Standard
Post by: Inaba on May 23, 2012, 12:50:56 PM
Quote
The number and order of fields in each api should be standardised.

JSON makes both of these immaterial.  No need to have them ordered and it would impose an undue burden on the pool side.  The number of fields would also be immaterial, just discard the fields you don't want to use.  That way it allows a pool to provide additional information beyond the standard.

Quote
The api call should be standardised -
eg the following could call worker stats:

This is nice in theory, but I'm not sure it can work in practice, given all the different systems out there. In your example it would create a supremely difficult problem for me to provide since I'm not setup to handle calls in that fashion.  If we are going to standardize in this fashion, HTTP GET is probably the best solution, since it should be universally compatible.

Quote
What if user (or few of his workers) are PPS? null value?

Zero would be the logical amount, since it would be an accurate value.

Quote
UTC, not GMT! GMT has summer/winter time, which is always pain in applications.

Yes!  Sorry I meant UTC not GMT!

Quote
Let's rename it to balance, balance_unconfirmed, balance_paid. Otherwise we'll rename those fields for NMC?

I did that specifically so you could add nmc_balance, nmc_unconfirmed, and nmc_paid.  Although I suppose we could make them a sub array of BTC: or NMC: (or whatever other currency) and then just use balance, unconfirmed, paid.

Quote
Also, we should define some standard on ask rate from clients. I'm caching API calls for 30 seconds, but still I see some stupid users fetching JSON data every second. That's not only annoying, that also needs much more transfers than mining itself of those users (especially when they're CPU miners).

Yes, I absolutely agree.  I see the same things.



Title: Re: Pool API Standard
Post by: P_Shep on May 23, 2012, 04:20:56 PM
Have you guys seen Luke's BIP?

https://en.bitcoin.it/wiki/BIP_PoolAPI

Some interesting ideas on displaying balances. Very generic, so can be used for any currency.

Things like the API call and call rate I should think can be totally up to the pool. I don't think there's any need to standardise these.


Title: Re: Pool API Standard
Post by: slush on May 23, 2012, 05:08:13 PM
I did that specifically so you could add nmc_balance, nmc_unconfirmed, and nmc_paid.  Although I suppose we could make them a sub array of BTC: or NMC: (or whatever other currency) and then just use balance, unconfirmed, paid.

Having currency name in variable doesn't look smart. Then I prefer - separate calls completely (and have an api for every currency) or have separate section for every currency, like ...'balance': {'BTC': {'unconfirmed': 0, 'confirmed': 0, 'paid': 0}, 'NMC': {...}} ...


Title: Re: Pool API Standard
Post by: slush on May 23, 2012, 05:10:57 PM
Have you guys seen Luke's BIP?

Yes and I see it overcomplicated, especially that "collab" construction. Better to have more APIs than one huge monster, isn't it? I even think that current API should be split into more calls like account state (balances, address, etc) and worker states.


Title: Re: Pool API Standard
Post by: P_Shep on May 23, 2012, 05:43:10 PM
Yes and I see it overcomplicated, especially that "collab" construction.
Yes it is rather. I didn't intend such complexity.

Better to have more APIs than one huge monster, isn't it? I even think that current API should be split into more calls like account state (balances, address, etc) and worker states.

That was my original suggestion :)

but having structure:
balance =
{
  type = BTC
  confirmed = xxx
  unconfimed = xxx
  ...etc...
}

As an array inside the main structure also works for me.

user =
{
    ...
    balances = {array of balance}
    ...
}


Title: Re: Pool API Standard
Post by: kinlo on May 23, 2012, 10:18:16 PM
I'd suggest providing 2 API's/url's

One API that requires an API key, showing all the information related to that user.

A second api/url containing the pool data, global data that is not related to a specific user, so it can be retrieved by any user without an API key.  Examples are global hashrate, found blocks history and such.

Seperating them would make it easy for people to get full data on any pool without an account...

Perhaps a third url can be made like /standard_api_locations.txt where the location of both those url's are placed, so the user doesn't have to enter anything except the main pool url.


Title: Re: Pool API Standard
Post by: organofcorti on May 24, 2012, 01:12:32 AM
I think pool round history is probably better as a .csv than in JSON. It's much easier to use a dataframe when working with aggregates of data. Also much easier for the poor sods using excel to get a feel for their pool's recent history.

As Inaba said the number and order of fields in JSON is immaterial, but that's not the case in a dataframe, especially if you want to perform exactly the same operations on different dataframes from different pools.



Title: Re: Pool API Standard
Post by: slush on May 24, 2012, 06:13:43 AM
As Inaba said the number and order of fields in JSON is immaterial

To be exact, this is true only for keys of an array. Lists (and history of blocks should be definitely stored in list) are ordered. But I see your point. Actually I'm for defining JSON API as an standard, because it's usually easier to handle in applications, and provide alternate CSV API with block history only (from pool side it's just an iteration over original JSON and columns with expected order).


Title: Re: Pool API Standard
Post by: Inaba on May 24, 2012, 12:40:42 PM
I would agree, historical data is better provided as CSV.  The API should be for relevant current information that changes frequently.


Title: Re: Pool API Standard
Post by: kinlo on May 24, 2012, 01:58:08 PM
I would agree, historical data is better provided as CSV.  The API should be for relevant current information that changes frequently.

Json has overhead compared to csv.  However, csv is not extensible, and the information isn't that big, so the overhead doesn't matter that much.  I would prefer json over csv.  A simple (online) convertor can still be made for those that prefer to work with csv instead of json.  If it is a standard, such a convertor would be easy to write for all pools at once...


Title: Re: Pool API Standard
Post by: organofcorti on May 24, 2012, 03:27:43 PM
I would agree, historical data is better provided as CSV.  The API should be for relevant current information that changes frequently.

Json has overhead compared to csv.  However, csv is not extensible, and the information isn't that big, so the overhead doesn't matter that much.  I would prefer json over csv.  A simple (online) convertor can still be made for those that prefer to work with csv instead of json.  If it is a standard, such a convertor would be easy to write for all pools at once...

csv is only considered for historical data that would be easier to manipulate as a dataframe and needs updating only when a block is found.


Title: Re: Pool API Standard
Post by: P_Shep on May 24, 2012, 04:21:51 PM
CSV for block data sounds reasonable to me.


Title: Re: Pool API Standard
Post by: P_Shep on May 25, 2012, 04:41:20 PM
shares =
{
    "submitted" = <shares submitted>,
    "stale" = <shares deemed stale by pool>,
    "invalid" = <shares deemed invalid by pool>
}

block =
{
    "currency" = <BTC, NMC, etc...>
    "id" = <block ID>,
    "duration" = <seconds>,
    "shares_round" = {<'shares' for entire pool for the round (as defined above)>},
    "shares_user" = {<'shares' for all workers of the user for the round (as defined above)>}
}

balance =
{
    "currency" = <BTC, NameCoin, Ix, iO, etc.>,
    "confirmed" = <confirmed reward (>=120 valid blocks) in Satoshis>,
    "unconfirmed" = <unconfirmed reward (<120 valid blocks) in Satoshis>,
    "estimate" = <estimated reward for current round>,
    "last_pay" = <value of last payout in Satoshis>,
    "last_pay_time" = <time of last payout in unix time>,
    "total_pay" = <total value of payout in Satoshis>,
    "threshold" = <min confirmed reward before auto payout in Satoshis. 0 for no auto payment>
}

worker =
{
    "id" = <unique identifier>,
    "name" = <name / description>,
    "hashrate" = <worker hashrate>,
    "last_activity" = <last submitted share time in unix time>,
    "shares_round" = {<'shares' for current round (as defined above)>},
    "shares_reset" = {<'shares' since last user reset (as defined above)>},
    "shares_total" = {<'shares' for all time (as defined above)>},
    "reward_algo" = <reward algorithm identifier>,
    "fee" = <fee multiplier (1% = 0.01)>
}

user =
{
    "API" = 1.0.0
    "pool_MOTD" = <whatever the pool wants to tell us>,
    "pool_hashrate" = <entire pool current hashrate>,
    "pool_users" = <number of active users on the pool>,
    "pool_workers" = <number of active workers on the pool>,
    "current_round" = {<array of active 'block' (as defined above)>},
    "user_hashrate" = <current hashrate in H/s for all workers - implementation pool dependent>,
    "last_activity" = <last submitted share time in unix time>,
    "balances" = {<array of 'balance' (as defined above)>},
    "workers" = {<array of 'worker' (as defined above)>}
}

Where:
All time displays presented as UNIX epoc.
All hash rates presented as hashes per second.
'Satoshis' is the smallest value for the associated currency. i.e. For USD this would be 1c.


Title: Re: Pool API Standard
Post by: JinTu on June 01, 2012, 10:26:05 PM
block =
{
    "currency" = <BTC, NMC, etc...>
    "id" = <block ID>,
    "duration" = <seconds>,
    "shares_total" = <total shares submitted so far for round>,
    "shares_submitted" = <shares submitted by user (all workers)>
}

balance =
{
    "currency" = <BTC, NameCoin, Ix, iO, etc.>,
    "confirmed" = <confirmed reward (>=120 valid blocks) in Satoshis>,
    "unconfirmed" = <unconfirmed reward (<120 valid blocks) in Satoshis>,
    "estimate" = <estimated reward for current round>,
    "last_pay" = <value of last payout in Satoshis>,
    "last_pay_time" = <time of last payout in unix time>,
    "total_pay" = <total value of payout in Satoshis>,
    "threshold" = <min confirmed reward before auto payout in Satoshis. 0 for no auto payment>
}

worker =
{
    "id" = <unique identifier>,
    "name" = <name / description>,
    "hash_rate" = <worker hash rate>,
    "last_activity" = <last submitted share time in unix time>,
    "shares" = <shares submitted by worker in current round>,
    "shares_total" = <total shares submitted by worker (may be resetable by pool?)>,
    "reward_algo" = <reward algorithm identifier>,
    "fee" = <fee multiplier (1% = 0.01)>
}

user =
{
    "API" = 1.0.0
    "pool_MOTD" = <whatever the pool wants to tell us>,
    "pool_hash_rate" = <entire pool current hash rate>,
    "pool_users" = <number of active users on the pool>,
    "pool_workers" = <number of active workers on the pool>,
    "current_round" = {<array of active 'block' (as defined above)>},
    "hash_rate" = <current hash rate in H/s for all workers - implementation pool dependent>,
    "last_activity" = <last submitted share time in unix time>,
    "balances" = {<array of 'balance' (as defined above)>},
    "workers" = {<array of 'worker' (as defined above)>}
}

Where:
All time displays presented as UNIX epoc.
All hash rates presented as hashes per second.
'Satoshis' is the smallest value for the associated currency. i.e. For USD this would be 1c.

+1

I would love to see this implemented.


Title: Re: Pool API Standard
Post by: P_Shep on June 06, 2012, 08:22:25 PM
I (we!) missed a very important metric up there, invalid/stale shares. So I've tweaked it a bit.
Getting rather complicated now though! Didn't intend for it to go this way, but at least it's pretty complete!

https://bitcointalk.org/index.php?topic=83027.msg921816#msg921816


Title: Re: Pool API Standard
Post by: Luke-Jr on June 06, 2012, 08:26:26 PM
I (we!) missed a very important metric up there, invalid/stale shares. So I've tweaked it a bit.
Getting rather complicated now though! Didn't intend for it to go this way, but at least it's pretty complete!

https://bitcointalk.org/index.php?topic=83027.msg921816#msg921816
Did you update the wiki page with the specification?


Title: Re: Pool API Standard
Post by: P_Shep on June 06, 2012, 08:47:08 PM
I (we!) missed a very important metric up there, invalid/stale shares. So I've tweaked it a bit.
Getting rather complicated now though! Didn't intend for it to go this way, but at least it's pretty complete!

https://bitcointalk.org/index.php?topic=83027.msg921816#msg921816
Did you update the wiki page with the specification?

I should probably do that...


Title: Re: Pool API Standard
Post by: Tittiez on June 06, 2012, 09:35:59 PM
Reminds me of

https://i.imgur.com/M0LYX.png


Title: Re: Pool API Standard
Post by: P_Shep on June 06, 2012, 10:08:22 PM

Certainly does :D

but no standard exists for this yet... all have been proprietary.


Title: Re: Pool API Standard
Post by: -ck on June 07, 2012, 02:18:12 AM
Hoppable prop pools will not be wanting to give out that much information... of course that's their problem.


Title: Re: Pool API Standard
Post by: Luke-Jr on June 07, 2012, 02:37:57 AM
Hoppable prop pools will not be wanting to give out that much information... of course that's their problem.
That's why everything is optional.


Title: Re: Pool API Standard
Post by: P_Shep on June 07, 2012, 02:44:32 AM
Hoppable prop pools will not be wanting to give out that much information... of course that's their problem.
That's why everything is optional.

Word.


Title: Re: Pool API Standard
Post by: Luke-Jr on June 07, 2012, 03:22:29 AM
I (we!) missed a very important metric up there, invalid/stale shares. So I've tweaked it a bit.
Getting rather complicated now though! Didn't intend for it to go this way, but at least it's pretty complete!

https://bitcointalk.org/index.php?topic=83027.msg921816#msg921816
Did you update the wiki page with the specification?

I should probably do that...
Please try to edit the existing specification draft, rather than replace it entirely. I combined the two, but please double-check that I didn't miss anything. Note that JSON does not have Float or Time types, just Number.

I also made a quick pass over it to try to make it sensible for Bitcoin address mining.


Title: Re: Pool API Standard
Post by: kano on June 18, 2012, 12:56:54 PM
A suggestion (or 2) ... welcome to be ignored :)


Elapsed should 'almost' never be used unless there is an actual specific reason for it
How long has a block been around is a good example of when it shouldn't be used - that should be a timestamp
(and saying it makes it easier for recipient XYZ simply means you got it wrong)
Timestamp things and return those integer sec timestamps or float timeval if higher accuracy is required
Also, as I did in the cgminer API, include a 'now' with any data set that has timestamps
(the cgminer API STATUS header always has 'When' for that reason ... once I realised it was missing)
This resolves any issue of ever creating correct elapsed values if anyone wants to display them


Also - I like float MH/s not H/s since that is what everyone thinks in nowadays and yeah in the future it will be even bigger
1 TH/s is 1000000000000 H/s - that number is just way too big already ...
1000000.000000 MH/s is 'nicer' IMO :)


Title: Re: Pool API Standard
Post by: Luke-Jr on June 18, 2012, 01:34:04 PM
Elapsed should 'almost' never be used unless there is an actual specific reason for it
How long has a block been around is a good example of when it shouldn't be used - that should be a timestamp
It is a timestamp...

Also - I like float MH/s not H/s since that is what everyone thinks in nowadays and yeah in the future it will be even bigger
1 TH/s is 1000000000000 H/s - that number is just way too big already ...
1000000.000000 MH/s is 'nicer' IMO :)
1e12 is valid JSON.