Api to get the latest block number

Hi Can any one help me on api to get the latest block number for Algorand

1 Like

JS API:

#### Retrieving Latest Block Information

To retrieve the latest block’s information you would use the algod client wrapper functions shown below.

const algosdk = require('algosdk');

//Retrieve the token, server and port values for your installation in the algod.net
//and algod.token files within the data directory
const atoken = "d60cb951132a5fed9dde1abeadd4ea02b2c8d9815ee1eb1cb932941eaa3821c8";
const aserver = "http://127.0.0.1";
const aport = 8080;

const algodclient = new algosdk.Algod(atoken, aserver, aport);

(async () => {
    let lastround = (await algodclient.status()).lastRound;
    let block = (await algodclient.block(lastround));
    console.log( block );
})().catch(e => {
    console.log(e);
});

taken from
https://developer.algorand.org/docs/javascript-sdk

1 Like

https://developer.algorand.org/docs/build-apps/connect/#check-node-status-and-network-version
now shows all languages.

do we have any api or curl query to get it from Node. I have Algorand Node set up already.

See the new docs, Algorand Developer Portal

Call the *status* and *version* methods from the algod client to check the details of your connection. This information is also available through equivalent REST API calls and `goal` commands.

JavaScript Python Java Go cURL

curl -i -X GET \ -H “X-Algo-API-Token:” \ ‘http://:/v1/status’

goal

The status methods return information about the status of the node, such as the latest round, referred to as lastRound , from the perspective of the node you are connected to. Each of the SDKs may differ slightly in which information they return for each call. Shown below is the response from the REST API call.

Response

{ “lastRound”: 4243027, “lastConsensusVersion”: “GitHub - algorandfoundation/specs at 4a9db6a25595c6fd097cf9cc137cc83027787eaa”, “nextConsensusVersion”: “GitHub - algorandfoundation/specs at 4a9db6a25595c6fd097cf9cc137cc83027787eaa”, “nextConsensusVersionRound”: 4243028, “nextConsensusVersionSupported”: true, “timeSinceLastRound”: 4261519666, “catchupTime”: 0, “hasSyncedSinceStartup”: false }

@Maugli thanks for the quick help . Could you please let me know the Source of CURL queries