goody
July 31, 2020, 11:50am
1
Hey guys !!!
I’m trying to use the js sdk with purestake.io testnet api but i keep getting a BAD REQUEST error
const algosdk = require(“algosdk”)
const baseServer = ‘https://testnet-algorand.api.purestake.io/idx2 ’
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() => {
try{
// const info = await algodclient.accountInformation(account.addr)
// let acct_string = JSON.stringify(account_info)
console.log(“Account Info:”, algodclient)
}catch(e){
console.log(e.message)
}
}
main()
https://testnet-algorand.api.purestake.io/idx2 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
See https://developer.algorand.org/docs/reference/sdks/migration/#client-instantiations
1 Like
goody
July 31, 2020, 12:01pm
3
thanks @fabrice , i hope purestake can update their docs, its misleading
goody
July 31, 2020, 12:03pm
4
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
Tim
July 31, 2020, 9:31pm
6
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)