Bad request error

Hey guys !!!
I’m trying to use the js sdk with testnet api but i keep getting a BAD REQUEST error

const algosdk = require(“algosdk”)
const baseServer = ‘
const port = ‘’;
const token = {
‘X-API-Key’: ‘API KEY’

const algodclient = new algosdk.Algod(token,baseServer, token)

let account = algosdk.generateAccount();
// console.log(account.addr)
const main = async() => {
// const info = await algodclient.accountInformation(account.addr)
// let acct_string = JSON.stringify(account_info)
console.log(“Account Info:”, algodclient)
main() is for the Indexer V2 endpoint.

const algodclient = new algosdk.Algod(token,baseServer, token)

creates an Algod V1 client.

You should use instead:

let indexerClient = new algosdk.Indexer(indexer_token, indexer_server, indexer_port); // new


1 Like

thanks @fabrice, i hope purestake can update their docs, its misleading

can i get like a link to the updated docs ??
i have another error already algodclient.accountInformation is not a function
i’m trying to get the balance of an address

See for Indexer V2

Apologies for any confusion - we’ve updated the examples page and added new examples to the api-examples GitHub repo today.

There are also a few new notes about known issues in the v2 APIs and SDK implementations.

The specific call you are looking for in the above (for the JS SDK)
let accountLookup = await indexerClient.lookupAccountByID('ACCOUNT').do() console.log(accountLookup.account.amount)