As part of today’s 2.0.7 upgrade, Algorand released an important update to its Algod API — one that significantly alters the endpoints and will require some changes in order for you to use them. It also introduces a lot of great new functionality that wasn’t available in the previous version.
Here’s what you need to know.
Algod v1 Becomes Algod v2 + Indexer v2
The functionality that was part of Algod v1 is now separated into two distinct APIs:
- Algod v2: Exposes new API functionality for a wider feature set and lays the groundwork for future releases. Endpoints, generally speaking, interact with the current ledger state and the blockchain — calls like supply, status, and pending transactions along with posting transactions and compiling Teal are supported here. New powerful private methods have also been introduced for node maintainers.
- Indexer v2: A new indexer built as a separate binary that can run standalone or co-located with Algod. Supports singular write and multiple reader instances that leverage a database backend of your choice for faster lookups. Endpoints are designed for historical searching, including powerful features to understand account state at past rounds.
By and large, splitting the API and indexer into two binaries is a good thing. The Indexer works as a standalone service that reads committed blocks from the Algorand blockchain and maintains a database of transactions and accounts that are searchable and indexed. This means these stored blocks will be significantly faster to search and query. You’ll be able to natively:
- Search and filter accounts, transactions, assets, and asset balances with many different parameters including:
- Address (Sender|Receiver)
- Signature type
- Transaction type
- Asset holdings
- Asset name
- Look up historical account data for a particular round
- Result pagination
- Enriched transaction and account data:
- Confirmation round (block containing the transaction)
- Confirmation time
- Signature type
- Asset ID
- Close amount when applicable
- Human readable field names instead of the space-optimized protocol level names.
There are a number of additional technical improvements as well:
- Abstracted database layer, to support many different backend databases.
- Optimized postgres DB backend.
- User-defined API token.
Here are a couple of important points to remember as you plan to migrate your project:
- Although the Algod API v1 will become deprecated, it will continue to co-exist alongside v2 for some number of months.
- When the v1 API is removed, it will become a breaking change so it’s important to update your API calls.
- All the SDKs are updated already and can support the v2 features, but, there may be many changes to how the same task is executed between v1 and v2.
How to Migrate Code to the New API Endpoints
If you need to manually update, follow these steps as outlined by Algorand: https://developer.algorand.org/docs/reference/sdks/migration/.
If you are currently using the PureStake Algorand API service, the new Algod v2 and Indexer v2 are already available. You will need to log in to see the new endpoints. This update includes the 2.0.7 upgrade for MainNet and TestNet, as well as support for BetaNet Algod v2, which was already live. We may release additional changes in the coming weeks as needed.
To plan your migration from v1 to v2:
- Review the complete notes from the 2.0.7 release
- Review the new official Algorand OpenAPI specification files for v2
- Try it out in the Swagger UI in the PureStake developer portal when the networks are available, or with your favorite client software. PureStake will provide Swagger files specific to our service, endpoints may be subtracted from the full set listed in the OpenAPI specifications.
- For each API call you are currently making, identify where it has migrated and, in cases where it may be in two places, review the returned data to understand which works better for your use case.
- Update relevant Algorand SDKs to the most current versions for your projects and review the (in some cases) extensive differences between v1 and v2.
- Expect continued refinements to the API services post-launch as the new capabilities are better understood.
- Migrate sooner rather than later!