API V2 Migration Guide 🆕

In June 2020, Algorand introduced the V2 API for algod and deprecated the V1 API. Both APIs remain functional to allow developers time to transition their application code to the fully supported V2 endpoints. Simultaneously, Algorand introduced algorand-indexer with only a V2 API. Use this guide to update your preferred SDK for V2 client support and then transition your application to use V2 clients for algod and algorand-indexer where applicable.

Warning

The deprecation of the V1 API for algod will become a breaking change in a future release of the algod software. Please ensure your application code is migrated to the new V2 endpoints at this time.

Information

The kmd API remains unchanged at V1. There are no changes required for application code using the V1 kmd client. Reference kmd client instantiations below.

Update your SDK

JavaScript

# update using npm
npm install algosdk

# verify installed version
npm list algosdk

REST APIs by SDK Release

SDK Release Supported V1 APIs Supported V2 APIs
thru [email protected] algod, kmd n/a
from [email protected] kmd algod, algorand-indexer

Supported Library Imports

API V1 API (deprecated) V2 API (fully supported)
algod
const algosdk = require('algosdk');
const algosdk = require('algosdk');
indexer
// not implemented, use V2
const algosdk = require('algosdk'); // new

Client Instantiations

API Client Instantiation
algod
let algodClient = new algosdk.Algodv2(algod_token, algod_server, algod_port);
indexer
let indexerClient = new algosdk.Indexer(indexer_token, indexer_server, indexer_port); // new

Info

The JavaScript SDK V2 clients implements a new pattern when calling REST methods. Each will append .do() to the method call. Example: let status = (await algodclient.status().do());

Python

# update using pip
pip3 install py-algorand-sdk

# verify installed version
pip3 list | grep "py-algorand-sdk"

Supported Clients by Version

SDK Version Supported V1 APIs Supported V2 APIs
thru py-algorand-sdk 1.2.1 algod, kmd n/a
from py-algorand-sdk 1.3.0 kmd algod, algorand-indexer

Supported Library Imports

API V1 API (deprecated) V2 API (fully supported)
algod
from algosdk import algod # deprecated
from algosdk.v2client import algod # fully supported
indexer
# not implemented, use V2
from algosdk.v2client import indexer # new

Client Instantiations

API Client Instantiation
algod
algod_client = algod.AlgodClient(algod_token, algod_address)
indexer
indexer_client = indexer.IndexerClient(indexer_token, indexer_address) //new

Java

Maven:
<dependency>
    <groupId>com.algorand</groupId>
    <artifactId>algosdk</artifactId>
    <version>1.4.1</version>
</dependency>

Supported Clients by Version

SDK Version Supported V1 APIs Supported V2 APIs
thru java-algorand-sdk 1.3.1 algod, kmd n/a
from java-algorand-sdk 1.4.1 kmd algod, algorand-indexer

Supported Library Imports

API V1 API (deprecated) V2 API (fully supported)
algod
import com.algorand.algosdk.algod.client.AlgodClient;
import com.algorand.algosdk.algod.client.auth.ApiKeyAuth;
import com.algorand.algosdk.v2.client.common.AlgodClient;
indexer
// not implemented, use V2
import com.algorand.algosdk.v2.client.common.IndexerClient; // new

Client Instantiations

API Client Instantiation
algod
AlgodClient client = (AlgodClient) new AlgodClient(ALGOD_API_ADDR, ALGOD_PORT, ALGOD_API_TOKEN);
indexer
IndexerClient indexerClient = (AlgodClient) new IndexerClient(INDEXER_API_ADDR, INDEXER_PORT);

Info

The Java SDK V2 clients implements a new pattern when calling REST methods. Each will append .execute() to the method call. Example: Long lastRound = client.GetStatus().execute().body().lastRound;

Go

go get -u github.com/algorand/go-algorand-sdk/...
make build

Supported Clients by Version

SDK Version Supported V1 APIs Supported V2 APIs
thru go-algorand-sdk 1.3.0 algod, kmd n/a
from go-algorand-sdk 1.4.2 kmd algod, algorand-indexer

Supported Library Imports

API V1 API (deprecated) V2 API (fully supported)
algod
import ( 
    "github.com/algorand/go-algorand-sdk/client/algod" 
)
import ( 
    "github.com/algorand/go-algorand-sdk/client/v2/algod" 
)
indexer
// not implemented, use V2
import ( 
    "github.com/algorand/go-algorand-sdk/client/v2/indexer" 
) // new

Client Instantiations

API Client Instantiation
algod
algodClient, err := algod.MakeClient(algodAddress, algodToken)
indexer
indexerClient, err := indexer.MakeClient(indexerAddress, indexerToken) // new

Info

The Go SDK V2 clients implements a new pattern when calling REST methods. Each will append .Do(context.Background()) to the method call. Example: status, err := client.Status().Do(context.Background())

kmd Client Instantiations

SDK Client Instantiation
JavaScript
let kmdClient = new algosdk.Kmd(kmd_token, kmd_server, kmd_port);
Python
kmd_client = algod.kmd(kmd_token, kmd_address)
Java
let kmdClient = new algosdk.Kmd(kmd_token, kmd_server, kmd_port);
Go
kmdClient, err := kmd.MakeClient(kmdAddress, kmdToken)