How to Connect to Algorand Mainnet

Learn how to connect to your Algorand infrastructure via REST API.

In this guide, you'll learn the following connection methods to the Algorand infrastructure:

👍

Note:

Visit the Algorand marketplace page to explore Blockdaemon’s Algorand infrastructure.


How to Access Your Blockdaemon Algorand Credentials

Once you have purchased your Blockdaemon Algorand infrastructure, you can access your credentials:

  1. Log into the Blockdaemon app.
  2. Click Nodes under the Access menu.
  3. Select the Algorand node.
  4. Select the Connect tab. You'll find the following information:
    1. Endpoint URL
    2. Auth String
    3. Auth Token

📘

Info:

Please reach out to [email protected] or your Customer Success Manager for support.


Connect to Algorand via the REST API

From a command line, you may use the REST API calls in the Algorand documentation and connect using the following pattern:

curl -X GET "YOUR_ENDPOINT_URL/v1/status?auth=YOUR_AUTH_TOKEN" \
-H "X-Algo-API-Token: YOUR_API_KEY"

Connect to Algorand via WebSocket

wscat -H "X-Auth-Token: YOUR_AUTH_TOKEN" -c wss://YOUR_ENDPOINT_URL:8443/websocket

📘

Info:

wscat is a tool that can connect over WebSocket(s) and may need to be installed. You can use your preferred tool of choice.


Connect to Algorand via Python

import algosdk
# Node Access
client = algosdk.v2client.algod.AlgodClient('', '', {
'X-Auth-Token': ''
})
resp = client.status()
print(resp)

Connect to Algorand via Go

package main
import (
"fmt"
"github.com/algorand/go-algorand-sdk/client/algod"
)
const algodAddress = ""
const algodToken = "Your_algorand_api_token"
func main() {
// Create an algod client
algodClient, err := algod.MakeClientWithHeaders(algodAddress, algodToken, []*algod.Header{
{
Key: "X-Auth-Token",
Value: "",
},
})Go
if err != nil {
return
}
// Print algod status
nodeStatus, err := algodClient.Status()
if err != nil {
fmt.Printf("error getting algod status: %s\n", err)
return
}
fmt.Printf("algod last round: %d\n", nodeStatus.LastRound)
fmt.Printf("algod time since last round: %d\n", nodeStatus.TimeSinceLastRound)
fmt.Printf("algod catchup: %d\n", nodeStatus.CatchupTime)
fmt.Printf("algod latest version: %s\n", nodeStatus.LastVersion)

📘

Info:

You can access a sample Go SDK for Algorand here.


Connect to Algorand via JavaScript

import algosdk from 'algosdk'
const token = '';
const server = '';
const port = 443;
const client = new algosdk.Algod(token, server, port, {
'X-Auth-Token': ''
});
(async () => {
console.log(await client.status());
})().catch((e) => {
console.log(e);
});

👋 Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.