> ## Documentation Index
> Fetch the complete documentation index at: https://developers.stellar.org/llms.txt
> Use this file to discover all available pages before exploring further.

# getLatestLedger

> Returns latest known ledger

For finding out the current latest known ledger of this node. This is a subset of the ledger info from Horizon.

## Params (0)

## Result

*(getLatestLedgerResponse)*

**id** `string`

Hash identifier of the latest ledger (as a hex-encoded string) known to Stellar RPC at the time it handled the request.

**protocolVersion** `number`

Stellar Core protocol version associated with the latest ledger.

**sequence** `number`

The sequence number of the latest ledger known to Stellar RPC at the time it handled the request.

**closeTime** `string`

The timestamp at which the latest ledger was closed.

**headerXdr** `string`

The [LedgerHeader](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger.x#L74) structure for this ledger (base64-encoded string).

**metadataXdr** `string`

The [LedgerCloseMeta](https://github.com/stellar/stellar-xdr/blob/v22.0/Stellar-ledger.x#L539) union for this ledger (base64-encoded string).

## Example

Example request to the `getLatestLedger` method.

**Request**

```bash cURL theme={"theme":{"light":"github-light","dark":"github-dark"}}
curl -X POST \
-H 'Content-Type: application/json' \
-d '{
  "jsonrpc": "2.0",
  "id": 8675309,
  "method": "getLatestLedger"
}' \
https://soroban-testnet.stellar.org | jq
```

```js JavaScript theme={"theme":{"light":"github-light","dark":"github-dark"}}
let requestBody = {
  jsonrpc: "2.0",
  id: 8675309,
  method: "getLatestLedger",
};
let res = await fetch("https://soroban-testnet.stellar.org", {
  method: "POST",
  headers: {
    "Content-Type": "application/json",
  },
  body: JSON.stringify(requestBody),
});
let json = await res.json();
console.log(json);
```

```python Python theme={"theme":{"light":"github-light","dark":"github-dark"}}
import json, requests
res = requests.post("https://soroban-testnet.stellar.org", json={
    "jsonrpc": "2.0",
    "id": 8675309,
    "method": "getLatestLedger"
})
print(json.dumps(res.json(), indent=4))
```

```json JSON theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "jsonrpc": "2.0",
  "id": 8675309,
  "method": "getLatestLedger"
}
```

**Result**

```json theme={"theme":{"light":"github-light","dark":"github-dark"}}
{
  "jsonrpc": "2.0",
  "id": 8675309,
  "result": {
    "id": "0a00a9cf845f7af7cff09c66f8ae6480e9971e6e2c7fa4afd8d6266ee13c987b",
    "protocolVersion": 27,
    "sequence": 3730795,
    "closeTime": "1784671645",
    "headerXdr": "CgCpz4RfevfP8Jxm+K5kgOmXHm4sf6Sv2NYmbuE8mHsAAAAbPDCnSG7CFV5/XNDJYU2mvuu7CWlGNETvjzmCB0C50X5Gm4bj+oLrMFjstd6bh+ahjUzOP//fanfkb6k4aruZ5AAAAABqX+2dAAAAAAAAAAEAAAAAtV0Qsrt9KE7VwDpHpeG1kMkPV4NVRxzEUHu+ggTSPIsAAABAcQoxoLTb8SJEAvsbXAetyT2GQeK8HMiN7z2TO4fX56R5roEd2xX5m2ii+FFlVQVErhT4KyxzN/hrbI+v2+9sCzMpCKVWHZKHWvI6d7MnLM0IZhhLZm9Cn43fPxlU5GgZVltQFYhVosSJDb2y8JpoHXePt07R4yONinsPVmZOHtwAOO1rDeC2s6dkAAAAAAO/vpEtPgAAAAAAAAAAAAX17QAAAGQATEtAAAAAyLgswiH76a8cJSTERunnOprBVOsw45eBswHJBh7QOH2GLf4GYAUflwJZdUz+pzyE1xTDFw9wViEEzJVHfgfPMfVBLqU1/WkTSpJrvCDw5YFOwWdTeyV4aQPW1Rg9Gm2gczzsqyuzzw6m/Ea/p4qmm6HSB3cImxjm7GK6fewJsfUzAAAAAAAAAAA=",
    "metadataXdr": "AAAAAgAAAAAKAKnPhF9698/wnGb4rmSA6Zcebix/pK/Y1iZu4TyYewAAABs8MKdIbsIVXn9c0MlhTaa+67sJaUY0RO+POYIHQLnRfkabhuP6guswWOy13puH5qGNTM4//99qd+RvqThqu5nkAAAAAGpf7Z0AAAAAAAAAAQAAAAC1XRCyu30oTtXAOkel4bWQyQ9Xg1VHHMRQe76CBNI8iwAAAEBxCjGgtNvxIkQC+xtcB63JPYZB4rwcyI3vPZM7…(truncated for brevity; the full base64 LedgerCloseMeta is large)"
  }
}
```

### Using the Lab

You can check the **latest known ledger** on both **Testnet** and **Mainnet** using the `getLatestLedger` RPC method directly in the [Stellar Laboratory](https://laboratory.stellar.org).

👉 [View Testnet Latest Ledger on the Lab](https://lab.stellar.org/endpoints/rpc/get-latest-ledger?\$=network\$id=testnet\&label=Testnet\&horizonUrl=https:////horizon-testnet.stellar.org\&rpcUrl=https:////soroban-testnet.stellar.org\&passphrase=Test%20SDF%20Network%20/;%20September%202015;;)

![Lab: getLatestLedger](https://mintcdn.com/stellardevelopmentfoundation/1iVxlvEjme-PeN5h/assets/api/rpc/getlatestledger.png?fit=max\&auto=format\&n=1iVxlvEjme-PeN5h\&q=85\&s=702c1692461fdd4b9822800570af355e)
