Skip to content

Commit fc3fb54

Browse files
authored
Merge pull request #150 from linuxion/patch-4
Update API_DOCUMENTATION_EN.md
2 parents 14bcba9 + 6fed3ca commit fc3fb54

1 file changed

Lines changed: 69 additions & 38 deletions

File tree

API_DOCUMENTATION_EN.md

Lines changed: 69 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,37 @@
1-
### [Blockchair.com](https://blockchair.com/) API v.2.0.6 Documentation
2-
3-
#### Changelog
1+
## [Blockchair.com](https://blockchair.com/) API v.2.0.6 Documentation
2+
3+
![alt text](https://blockchair.com/images/logo_full.png "Blockchair logo")
4+
5+
### Table of contents
6+
7+
+ [Changelog](#changelog)
8+
+ [Tested features changelog](#tested-features-changelog)
9+
+ [General Provisions](#general-provisions)
10+
+ [Infinitable Calls (blockhain tables)](#infinitable-calls-blockhain-tables)
11+
+ Bitcoin, Bitcoin Cash, Litecoin
12+
+ [Blocks](#bitcoin-cashlitecoinmempoolblocks)
13+
+ [Transaction](#bitcoin-cashlitecoinmempooltransactions)
14+
+ [Outputs](#bitcoin-cashlitecoinmempooloutputs)
15+
+ Ethereum
16+
+ [Blocks](#ethereummempoolblocks)
17+
+ [Uncles](#ethereumuncles)
18+
+ [Transactions](#ethereummempooltransactions)
19+
+ [Calls](#ethereumcalls)
20+
+ [Notes](#notes)
21+
+ [Dashboard calls](#dashboard-calls)
22+
+ [Blocks](#bitcoin-cashlitecoinethereumdashboardsblocka-and-bitcoin-cashlitecoinethereumdashboardsblocksab)
23+
+ [Uncles (Ethereum)](#ethereumdashboardsunclea-and-ethereumdashboardsunclesab)
24+
+ [Transactions](#bitcoin-cashlitecoinethereumdashboardstransactiona-and-bitcoin-cashlitecoinethereumdashboardstransactionsab)
25+
+ [Unconfirmed transactions priority (in mempool)](#bitcoin-cashlitecoinethereumdashboardstransactionhashpriority)
26+
+ [Address (Bitcoin, Bitcoin Cash, Litecoin)](#bitcoin-cashlitecoindashboardsaddressa)
27+
+ [Address (Ethereum)](#ethereumdashboardsaddressa)
28+
+ [Stats](#bitcoin-cashlitecoinethereumstats)
29+
+ [General stats](#stats)
30+
+ [API request example](#api-request-examples)
31+
+ [Support](#support)
32+
33+
34+
### Changelog
435

536
* v.2.0.6 - Oct 8th - Added data aggregation of blockchain data in beta mode, see `Data aggregation support` below
637
* v.2.0.5 - Oct 8th - Fixed bug where `balance` and `received` for bitcoin[-cash]|litecoin addresses in the `{chain}/dashboards/address/{address}` call were calculated wrong if there were specific unconfirmed transactions
@@ -9,7 +40,7 @@
940
* v.2.0.2 - Sep 9th - Added `address.contract_created` to the `ethereum/dashboards/address/{A}` call
1041
* v.2.0.1 - Sep 1st - Added Litecoin support
1142

12-
#### Tested features changelog
43+
### Tested features changelog
1344

1445
##### Data aggregation support (since Oct 8th)
1546

@@ -25,34 +56,34 @@ To use aggregation, put the fields by which you'd like to group by (zero, one, o
2556

2657
Possible fields:
2758
* Bitcoin, Bitcoin Cash, Litecoin:
28-
* Blocks table
59+
* [Blocks table](#bitcoin-cashlitecoinmempoolblocks)
2960
* Group by: date (or week, month, year), version, guessed_miner
30-
* To calculate: size, stripped_size (except BCH), weight (except BCH), transaction_count, witness_count, input_count, output_count, input_total, input_total_usd, output_total, output_total_usd, fee_total, fee_total_usd, fee_per_kb, fee_per_kb_usd, fee_per_kwu (except BCH), fee_per_kwu_usd (except BCH), cdd_total, generation, generation_usd, reward, reward_usd -- possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
31-
* Transactions table
61+
* To calculate: size, stripped_size (except BCH), weight (except BCH), transaction_count, witness_count, input_count, output_count, input_total, input_total_usd, output_total, output_total_usd, fee_total, fee_total_usd, fee_per_kb, fee_per_kb_usd, fee_per_kwu (except BCH), fee_per_kwu_usd (except BCH), cdd_total, generation, generation_usd, reward, reward_usd possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
62+
* [Transactions table](#bitcoin-cashlitecoinmempooltransactions)
3263
* Group by: block_id, date (or week, month, year), version, is_coinbase, has_witness (except BCH), input_count, output_count
33-
* To calculate: size, weight (except BCH), input_count, output_count, input_total, input_total_usd, output_total, output_total_usd, fee, fee_usd, fee_per_kb, fee_per_kb_usd, fee_per_kwu (except BCH), fee_per_kwu_usd (except BCH), cdd_total -- possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
34-
* Outputs table
64+
* To calculate: size, weight (except BCH), input_count, output_count, input_total, input_total_usd, output_total, output_total_usd, fee, fee_usd, fee_per_kb, fee_per_kb_usd, fee_per_kwu (except BCH), fee_per_kwu_usd (except BCH), cdd_total possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
65+
* [Outputs table](#bitcoin-cashlitecoinmempooloutputs)
3566
* Group by: block_id, date (or week, month, year), type, is_from_coinbase, is_spendable, is_spent, spending_block_id, spending_date (no support for spending_week, spending_month, spending_year yet)
36-
* To calculate: value, value_usd, spending_value_usd, lifespan, cdd -- possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
67+
* To calculate: value, value_usd, spending_value_usd, lifespan, cdd possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
3768
* Ethereum:
38-
* Blocks table
69+
* [Blocks table](#ethereummempoolblocks)
3970
* Group by: date (or week, month, year), miner
40-
* To calculate: size, difficulty, gas_used, gas_limit, uncle_count, transaction_count, synthetic_transaction_count, call_count, synthetic_call_count, value_total, value_total_usd, internal_value_total, internal_value_total_usd, generation, generation_usd, uncle_generation, uncle_generation_usd, fee_total, fee_total_usd, reward, reward_usd -- possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
41-
* Uncles table
71+
* To calculate: size, difficulty, gas_used, gas_limit, uncle_count, transaction_count, synthetic_transaction_count, call_count, synthetic_call_count, value_total, value_total_usd, internal_value_total, internal_value_total_usd, generation, generation_usd, uncle_generation, uncle_generation_usd, fee_total, fee_total_usd, reward, reward_usd possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
72+
* [Uncles table](#ethereumuncles)
4273
* Group by: parent_block_id, date (or week, month, year), miner
43-
* To calculate: size, difficulty, gas_used, gas_limit, generation, generation_usd -- possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
44-
* Transactions table
74+
* To calculate: size, difficulty, gas_used, gas_limit, generation, generation_usd possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
75+
* [Transactions table](#ethereummempooltransactions)
4576
* Group by: block_id, date (or week, month, year), failed, type
46-
* To calculate: call_count, value, value_usd, internal_value, internal_value_usd, fee, fee_usd, gas_used, gas_limit, gas_price -- possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
47-
* Calls table
77+
* To calculate: call_count, value, value_usd, internal_value, internal_value_usd, fee, fee_usd, gas_used, gas_limit, gas_price possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
78+
* [Calls table](#ethereumcalls)
4879
* Group by: block_id, date (or week, month, year), failed, fail_reason, type, transferred
49-
* To calculate: child_call_count, value, value_usd -- possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
80+
* To calculate: child_call_count, value, value_usd possible functions: avg(field), median(field), min(field), max(field), sum(field), count()
5081

5182
##### Omni Layer and Wormhole support (since Sep 18th)
5283

5384
* v.a1 - Sep 18th - Added alpha support for Omni Layer in Bitcoin (`bitcoin/omni/properties`, `bitcoin/omni/dashboards/property/{id}` calls, plus `_omni` key in the `bitcoin/dashboards/transaction` call and `_omni` key in the `bitcoin/dashboards/address` call), and support for Wormhole in Bitcoin Cash (`bitcoin-cash/wormhole/properties`, `bitcoin-cash/wormhole/dashboards/property/{id}` calls, plus `_wormhole` key in the `bitcoin-cash/dashboards/transaction` call and `_wormhole` key in the `bitcoin-cash/dashboards/address` call). Please don't use this in production yet, there will be massive changes!
5485

55-
#### General Provisions
86+
### General Provisions
5687

5788
* Requests to our server should be made through the HTTPS protocol by GET requests to the domain `api.blockchair.com`
5889

@@ -149,7 +180,7 @@ If you need to apply several sorts, you can list them by commas, similar to filt
149180

150181
**Offset** can be used as a paginator, e.g., `?offset=10` returns the next 10 results. `context.offset` takes the value of the set `OFFSET`. The maximum value is 10000. If you need just the last page, it's easier and quicker to change the direction of the sorting to the opposite. Important: when iterating through the results, it is extremely likely that the number of rows in the database will increase because new blocks were found. To avoid that, you may add an additional condition that limits the block id to the value obtained in `context.state` in the first query.
151182

152-
##### (bitcoin[-cash]|litecoin)/[mempool/]blocks
183+
#### (bitcoin[-cash]|litecoin)/[mempool/]blocks
153184

154185
Returns data about blocks
155186

@@ -206,7 +237,7 @@ Notes:
206237
- (\*) - only for Bitcoin
207238
- the default sorting - id DESC
208239

209-
##### (bitcoin[-cash]|litecoin)/[mempool/]transactions
240+
#### (bitcoin[-cash]|litecoin)/[mempool/]transactions
210241

211242
Returns transaction data
212243

@@ -243,7 +274,7 @@ Notes:
243274
- (\*) - only for Bitcoin
244275
- the default sort is id DESC
245276

246-
##### (bitcoin[-cash]|litecoin)/[mempool/]outputs
277+
#### (bitcoin[-cash]|litecoin)/[mempool/]outputs
247278

248279
Returns information about the outputs (that become inputs when they are spent, and then `spending*` information appears)
249280

@@ -289,7 +320,7 @@ Notes:
289320
- (\*) - only for Bitcoin
290321
- the default sort is - transaction_id DESC
291322

292-
##### ethereum/[mempool/]blocks
323+
#### ethereum/[mempool/]blocks
293324

294325
Returns block data
295326

@@ -346,7 +377,7 @@ Notes:
346377
- the difference between `value_total` and `internal_value_total`: e.g., a transaction itself sends 0 eth, but this transaction is a call of a contract that sends someone, let's say, 10 eth. Then `value` will be 0 eth, and `internal_value` - 10 eth
347378
- the default sort is id DESC
348379

349-
##### ethereum/uncles
380+
#### ethereum/uncles
350381

351382
Returns information about uncles
352383

@@ -388,7 +419,7 @@ Notes:
388419
- the search over `extra_data_hex` column can be done by the operator `^`, you can also use `~` for `extra_data_bin` (however, the field `extra_data_bin` will still not be shown)
389420
- sort by default - parent_block_id DESC
390421

391-
##### ethereum/[mempool/]transactions
422+
#### ethereum/[mempool/]transactions
392423

393424
Returns transaction information
394425

@@ -444,7 +475,7 @@ Notes:
444475
* create_tree - create a new contract that create contracts or starts making calls
445476
* synthetic_coinbase - a synthetic transaction for awarding a reward to the miner (block or uncle)
446477

447-
##### ethereum/calls
478+
#### ethereum/calls
448479

449480
Returns information about calls
450481

@@ -478,18 +509,18 @@ Notes:
478509
- the default sort is transaction_id DESC
479510
- sorting by `index` is alphabetical (ie "0.2" goes after "0.11"), in some cases a switch to natural sorting is used (for example, when there is a filter for `transaction_id`)
480511

481-
##### Notes
512+
#### Notes
482513

483514
- for unconfirmed transactions (and outputs in the case of bitcoin[-cash]), the following rules are applied:
484515
- their `block_id` is equal to `-1`
485516
- `date` and` time` indicate the time when the transaction was received by our node
486517
- when using `offset`, it is reasonable to add to the filters the maximum block number (`?q=block_id(..N)`), since it is very likely that during the iteration new rows will be added to the table. For convenience, you can take the value of `context.state` from the first result of any query containing the number of the latest block at the query time and use this result later on.
487518

488-
#### Dashboard calls
519+
### Dashboard calls
489520

490521
The API supports a number of calls that produce some aggregated data, or data in a more convenient form for certain entities.
491522

492-
##### (bitcoin[-cash]|litecoin|ethereum)/dashboards/block/{A} and (bitcoin[-cash]|litecoin|ethereum)/dashboards/blocks/{A[,B,...]}
523+
#### (bitcoin[-cash]|litecoin|ethereum)/dashboards/block/{A} and (bitcoin[-cash]|litecoin|ethereum)/dashboards/blocks/{A[,B,...]}
493524

494525
As the input data, it takes the height or hash of the block(s). `data` returns an array with block heights or block hashes used as keys, and arrays of elements as values:
495526
* `block` - information about the block in infinitable-format `(bitcoin[-cash]|ethereum)/blocks`
@@ -499,14 +530,14 @@ As the input data, it takes the height or hash of the block(s). `data` returns a
499530

500531
`context.results` contains the number of found blocks.
501532

502-
##### ethereum/dashboards/uncle/{A} and ethereum/dashboards/uncles/{A[,B,...]}
533+
#### ethereum/dashboards/uncle/{A} and ethereum/dashboards/uncles/{A[,B,...]}
503534

504535
As the input data, it takes an uncle hash(es). `data` returns an array with uncle hashes used as keys, and arrays of elements as values:
505536
* `uncle` - information about the block in infinitable-format `ethereum/uncles`
506537

507538
`context.results` contains the number of found uncles.
508539

509-
##### (bitcoin[-cash]|litecoin|ethereum)/dashboards/transaction/{A} and (bitcoin[-cash]|litecoin|ethereum)/dashboards/transactions/{A[,B,...]}
540+
#### (bitcoin[-cash]|litecoin|ethereum)/dashboards/transaction/{A} and (bitcoin[-cash]|litecoin|ethereum)/dashboards/transactions/{A[,B,...]}
510541

511542
At the input data, it takes an internal blockchair-id or a hash of a transaction (transactions). `data` returns an array with identifiers or hashes of transactions used as keys, and arrays of elements as keys:
512543
* `transaction` - transaction information in infinitable-format `bitcoin[-cash]/transactions`
@@ -516,11 +547,11 @@ At the input data, it takes an internal blockchair-id or a hash of a transaction
516547

517548
`context.results` contains the number of found transactions.
518549

519-
##### (bitcoin[-cash]|litecoin|ethereum)/dashboards/transaction/{hash}/priority
550+
#### (bitcoin[-cash]|litecoin|ethereum)/dashboards/transaction/{hash}/priority
520551

521552
For mempool transactions shows priority (`position`) (for Bitcoin - by `fee_per_kwu`, for Bitcoin Cash - by `fee_per_kb`, for Ethereum - by `gas_price`) over other transactions (`out_of` mempool transactions). It has the same structure as the `(bitcoin[-cash]|ethereum)/dashboards/transaction/{A}` call
522553

523-
##### (bitcoin[-cash]|litecoin)/dashboards/address/{A}
554+
#### (bitcoin[-cash]|litecoin)/dashboards/address/{A}
524555

525556
Uses address as the input data. `data` returns an array with one element (if the address is found), in that case the address is the key, and the value is an array consisting of the following elements:
526557
* `address`
@@ -545,7 +576,7 @@ Uses address as the input data. `data` returns an array with one element (if the
545576

546577
To iterate `transactions`, `?offset=N` is supported.
547578

548-
##### ethereum/dashboards/address/{A}
579+
#### ethereum/dashboards/address/{A}
549580

550581
Uses address as the input data. `data` returns an array with one element (if the address is found), in that case the address is the key, and the value is an array consisting of the following elements:
551582
* `address`
@@ -579,7 +610,7 @@ Notes:
579610
- (\*) - in these columns, the value in wei can be rounded. For a million of calls, the error can be more than 1 ether.
580611
- (\*\*) - counted only those calls that fit the following condition: ethereum/calls.transferred = true (see the `ethereum/calls` documentation), i.e. those calls as well as failed calls that do not change state (staticcall, etc.) are not considered
581612

582-
##### (bitcoin[-cash]|litecoin|ethereum)/stats
613+
#### (bitcoin[-cash]|litecoin|ethereum)/stats
583614

584615
Returns an array with blockchain statistics:
585616
* `blocks` - total number of blocks
@@ -610,15 +641,15 @@ Returns an array with blockchain statistics:
610641
* `market_dominance_percentage` - dominance index (how much % of the total cryptocurrency market is the market capitalization of the coin)
611642
... there's also some other self-explanatory keys
612643

613-
##### stats
644+
#### stats
614645

615646
Returns data on four calls:
616647
* `bitcoin/stats`
617648
* `bitcoin-cash/stats`
618649
* `ethereum/stats`
619650
* `litecoin/stats`
620651

621-
#### API request examples
652+
### API request examples
622653

623654
Suppose we would like to receive all the latest transactions from the Ethereum blockchain which amount to more than $1M USD. The following request should be done for this:
624655
* `https://api.blockchair.com/ethereum/transactions?q=internal_value_usd(10000000..)&s=id(desc)`
@@ -633,7 +664,7 @@ From its result we save `context.state`, put it in a variable `_S_`, and further
633664

634665
Increase offset value until getting a data set with the transaction that we already knew about.
635666

636-
#### Support
667+
### Support
637668

638669
* E-mail: [info@blockchair.com](mailto:info@blockchair.com)
639670
* Telegram chat: [@Blockchair](https://telegram.me/Blockchair)

0 commit comments

Comments
 (0)