SQD Network API distributes the requests over a (potentially decentralized) network of workers. The main gateway URL points at a router that provides URLs of workers that do the heavy lifting. Each worker has its own range of blocks on each dataset it serves. Suppose you want to retrieve an output of some query on a block range starting atDocumentation Index
Fetch the complete documentation index at: https://docs.sqd.dev/llms.txt
Use this file to discover all available pages before exploring further.
firstBlock (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.
