1

I have an Insight API Server running, it's fully synced and working. I would like to get a json to receive every tx within a block.

On https://github.com/bitpay/insight-api it says I have to use:

Transactions by Block
  /insight-api/txs/?block=HASH
  /insight-api/txs/?block=00000000fa6cf7367e50ad14eb0ca4737131f256fc4c5841fd3c3f140140e6b6

For example we take block #301453. This block has 725 transactions.

https://insight.bitpay.com/block/00000000000000004dff81aadf782cceb8a2d082f0f255472791c8bb2984e958

If I use the api to get the json file with this link:

http://localhost:3001/insight-api/txs/?block=00000000000000004dff81aadf782cceb8a2d082f0f255472791c8bb2984e958

... then it shows the first 10 transactions only (numbers 0 - 9). But there are 725 tx in this block.

It looks like the number 10 are those addresses are the first who are displayed. If i scroll further down, more transactions appear. But why does the json request only show 10 txs?

How can I get ALL transactions in this block - as the documentations mentions?

1 Answer 1

1

You have two options.

Option 1:
The returned json includes a "pageTotal":'some number'.
You can create a for-loop to loop through all the pages with API calls.

Let assume there are two pages aka "pageTotal":2

To fetch the first page, append parameter [&pageNum=0] to the end
Example usage:

http://localhost:3001/insight-api/txs/?block=00000000000000004dff81aadf782cceb8a2d082f0f255472791c8bb2984e958&pageNum=0

To fetch the second page, add param [&pageNum=1]
Example usage:

http://localhost:3001/insight-api/txs/?block=00000000000000004dff81aadf782cceb8a2d082f0f255472791c8bb2984e958&pageNum=1


Option 2:
Modify transactions.js , 'var pageLength' on Line 253.
The default is 'var pageLength = 10;'
Unsure if there are consequences by doing this, but I assume it should be fine.

1
  • Thanks! I changed "var pageLength" to 50000. This should list 50.000 tx and should last a while. :) I think option two is the faster solution.
    – A.c
    Dec 21, 2017 at 23:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.