Tron SQD Network API
Open private SQD Network offers access to Tron data. The gateway is atfirstBlock (can be the genesis block) and ending at the highest available block. Proceed as follows:
-
Retrieve the dataset height from the router with
GET /heightand make sure it’s abovefirstBlock. -
Save the value of
firstBlockto some variable, saycurrentBlock. -
Query the router for an URL of a worker that has the data for
currentBlockwithGET /${currentBlock}/worker. -
Retrieve the data from the worker by posting the query (
POST /), setting the"fromBlock"query field to${currentBlock}. -
Parse the retrieved data to get a batch of query data plus the height of the last block available from the current worker. Take the
header.numberfield of the last element of the retrieved JSON array - it is the height you want. Even if your query returns no data, you’ll still get the block data for the last block in the range, so this procedure is safe. -
Set
currentBlockto the height from the previous step plus one. - Repeat steps 3-6 until all the required data is retrieved.
Manually with cURL
Manually with cURL
Suppose we want data on token burns from block 58_000_000. We have to:
-
Verify that the dataset has reached the required height:
Output
- Remember that your current height is 58000000.
-
Get a worker URL for the current height
Output
-
Retrieve the data from the worker
Output:
-
Observe that we received the transactions up to and including block 16031419. To get the rest of the data, we find a worker who has blocks from 16031420 on:
Output:We can see that this part of the dataset is located on another host.
-
Retrieve the data from the new worker
Output is similar to that of step 3.
- Repeat steps 4 and 5 until the dataset height of 18593441 reached.
In Python
In Python
Router API
GET /height (get height of the dataset)
GET /height (get height of the dataset)
Example response:
65900614.GET ${firstBlock}/worker (get a suitable worker URL)
GET ${firstBlock}/worker (get a suitable worker URL)
The returned worker will be capable of processing
POST / requests in which the "fromBlock" field is equal to ${firstBlock}.Example response: https://rb06.sqd-archive.net/worker/query/czM6Ly90cm9uLW1haW5uZXQ.Worker API
POST / (query logs and transactions)
POST / (query logs and transactions)
Query Fields
- fromBlock: Block number to start from (inclusive).
- toBlock: (optional) Block number to end on (inclusive). If this is not given, the query will go on for a fixed amount of time or until it reaches the height of the dataset.
- includeAllBlocks: (optional) If true, the Network will include blocks that contain no data selected by data requests into its response.
- fields: (optional) A selector of data fields to retrieve. Common for all data items.
- logs: (optional) A list of log requests. An empty list requests no data.
- transactions: (optional) A list of general transaction requests. An empty list requests no data.
- transferTransactions: (optional) A list of “transfer” transaction requests. An empty list requests no data.
- transferAssetTransactions: (optional) A list of “transfer asset” transaction requests. An empty list requests no data.
- triggerSmartContractTransactions: (optional) A list of “trigger smart contract” transaction requests. An empty list requests no data.
- internalTransactions: (optional) A list of internal transaction requests. An empty list requests no data.
Example Request
Example Request
Example Response
Example Response
Data requests
Logs
address: the set of addresses of contracts emitting the logs. Omit to subscribe to events from all contracts in the network.topicN: the set of values of topicN.
null request matches any log.
With transaction: true all parent transactions will be included into the response.
Transactions
General
type: the set of acceptable transaction types.
type request in this case). An empty array matches no transactions; omitted or null request matches any transaction.
With logs: true all logs emitted by the transactions will be included into the response. With internalTransactions: true all the internal transactions induced by the selected transactions will be included into the response.
”transfer”
owner: the set of owner addresses for which the transfer transactions should be retrieved.to: the set of destination addresses.
null request matches any transaction.
With logs: true all logs emitted by the transactions will be included into the response. With internalTransactions: true all the internal transactions induced by the selected transactions will be included into the response.
”transfer asset”
owner: the set of owner addresses for which the transfer transactions should be retrieved.to: the set of destination addresses.asset: the set of asset contract addresses.
null request matches any transaction.
With logs: true all logs emitted by the transactions will be included into the response. With internalTransactions: true all the internal transactions induced by the selected transactions will be included into the response.
”trigger smart contract”
owner: the set of owner addresses for which the transfer transactions should be retrieved.to: the set of destination addresses.
null request matches any transaction.
With logs: true all logs emitted by the transactions will be included into the response. With internalTransactions: true all the internal transactions induced by the selected transactions will be included into the response.
Internal transactions
caller: the set of addresses of caller contracts.transferTo: the set of addresses of receivers of TRX or TRC10 tokens.
null request matches any transaction.
With transaction: true all parent transactions for the selected internal transactions will be included into the response.
Data fields selector
A selector of fields for the returned data items. Its structure is as follows:transaction field selector is common for all transaction types except for the internal transactions.
Block fields
true as values, e.g. {"hash": true, "timestamp": true}.
Log fields
true as values, e.g. {"address": true, "transactionHash": true}.
Transaction fields
true as values, e.g. {"hash": true, "type": true, "contractResult": true}.
Internal transaction fields
true as values, e.g. {"hash": true, "callerAddress": true, "callValueInfo": true}.