Since the Stacks Blockchain API depends on a Stacks blockchain node being at the same block height, you will need to first restore a Stacks blockchain node using the Hiro Archive before restoring the Stacks Blockchain API. Otherwise, you may encounter errors when running the API.
In order for the Stacks blockchain and Stacks Blockchain API archives to be compatible, they must meet the following criteria:
Both archives correspond to the same Stacks network (mainnet/testnet).
The API archive version must be compatible with the Stacks blockchain archive version (See API release notes for guidance).
There are two ways to restore a Stacks Blockchain API using the Hiro Archive. The archive file you'll need to download will depend on your method of restoration. There is no scenario where you would need both restoration methods.
Restore via Postgres database dump (Recommended)
This is the quickest and most direct method, and it is suitable for most scenarios. It consists of a backup of the API's Postgres database taken using pg_dump. We generally recommend starting with this method before attempting the method below if this one does not work for any reason.
Restore via tab-separated-values (TSV) file
This method is several times slower than restoring from a Postgres dump. The API TSV file contains the raw unprocessed events from a Stacks blockchain node. The API can ingest this file to process events into a Postgres database.
Restoring from a TSV file can be useful when a Postgres database archive for a particular API version is not available or when it cannot be used for any reason.
Import the archive file into a running Postgres database (may take up to an hour depending on database specs and tuning):
Launch the Stacks Blockchain API service.
Verify the dataset is being used by comparing your nodes local block height with Hiro's. If the block height matches or is close to Hiro's block height, the restoration was successful.
It may take a few minutes for the local node to respond on this endpoint.
Your block height may be up to a few hundred blocks away from Hiro's depending on the age of the archive. It should catch up relatively quickly.
If restoring via TSV file
Download the archive and shasum for the appropriate network and restoration method.
Follow these directions to process and import the events in the TSV file into your Postgres database.
Launch the Stacks Blockchain API service.
Verify the dataset is being used by comparing your nodes local block height with Hiro's. If the block height matches or is close to Hiro's block height, the restoration was successful.
It may take a few minutes for the local node to respond on this endpoint.
Your block height may be up to a few hundred blocks away from Hiro's depending on the age of the archive. It should catch up relatively quickly.