# ledger_entry - XRPL.

> Example code for the ledger_entry JSON RPC method. Complete guide to using ledger_entry JSON-RPC in the GetBlock Web3 documentation.

This method returns a single ledger entry from the XRP Ledger in its raw format.

## Parameters

| Parameter | Type | Required | Description |
| --- | --- | --- | --- |
| index | string | No | Object ID |
| account_root | string | No | Account address |
| directory | object | No | Directory specification |
| offer | object | No | Offer specification |
| ripple_state | object | No | Trust line specification |
| check | string | No | Check ID |
| escrow | object | No | Escrow specification |
| payment_channel | string | No | Channel ID |
| deposit_preauth | object | No | Preauth specification |
| ticket | object | No | Ticket specification |
| ledger_hash | string | No | Ledger hash |
| ledger_index | string/number | No | Ledger index |

## Request Examples

#### cURL

#### curl

```bash
curl --location --request POST 'https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "ledger_entry",
    "params": [{
        "account_root": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "ledger_index": "validated"
    }],
    "id": "getblock.io"
}'
```

#### JavaScript (Axios)

#### example.js

```javascript
const axios = require('axios');

const url = 'https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/';
const headers = {
    'Content-Type': 'application/json'
};

const payload = {
    jsonrpc: '2.0',
    method: 'ledger_entry',
    params: [{
        account_root: 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH',
        ledger_index: 'validated'
    }],
    id: 'getblock.io'
};

axios.post(url, payload, { headers })
    .then(response => console.log(response.data))
    .catch(error => console.error(error));
```

#### Python

#### example.py

```python
import requests

url = "https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/"
headers = {
   
    "Content-Type": "application/json"
}

payload = {
    "jsonrpc": "2.0",
    "method": "ledger_entry",
    "params": [{
        "account_root": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
        "ledger_index": "validated"
    }],
    "id": "getblock.io"
}

response = requests.post(url, headers=headers, json=payload)
print(response.json())
```

#### Rust

#### main.rs

```rust
use reqwest::Client;
use serde_json::json;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::new();
    
    let payload = json!({
        "jsonrpc": "2.0",
        "method": "ledger_entry",
        "params": [{
            "account_root": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "ledger_index": "validated"
        }],
        "id": "getblock.io"
    });

    let response = client
        .post("https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>/")

        .header("Content-Type", "application/json")
        .json(&payload)
        .send()
        .await?;

    let result: serde_json::Value = response.json().await?;
    println!("{:#?}", result);
    
    Ok(())
}
```

## Response Example

#### response.json

```json
{
    "result": {
        "index": "B1CB040A17F9469BC00376EC8719535655824AD16CB5F539DD5765FEA88FDBE3",
        "ledger_current_index": 102053097,
        "node": {
            "Account": "rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH",
            "Balance": "1070051282",
            "Flags": 0,
            "LedgerEntryType": "AccountRoot",
            "OwnerCount": 0,
            "PreviousTxnID": "8CA6DE7FCB677A4E59D34B782AF47298E8426E4C1F5774CD0F0185664C68CE52",
            "PreviousTxnLgrSeq": 100788827,
            "Sequence": 45,
            "index": "B1CB040A17F9469BC00376EC8719535655824AD16CB5F539DD5765FEA88FDBE3"
        },
        "status": "success",
        "validated": false
    }
}
```

## Response Parameters

| Parameter | Type | Description |
| --- | --- | --- |
| index | string | Object identifier |
| node | object | Entry data |
| ledger_index | integer | Ledger index |

## Use Cases

* Get specific entry
* Check account state
* Verify offers/escrows

## Error Handling

| Error Code | Description |
| --- | --- |
| entryNotFound | Entry not found |
| invalidParams | Invalid parameters |

## SDK Integration

#### xrpl.js

#### xrpl.js example

```javascript
const xrpl = require('xrpl');

async function getEntry() {
    const client = new xrpl.Client('wss://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>');
    await client.connect();
    
    const response = await client.request({
        command: 'ledger_entry',
        account_root: 'rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH'
    });
    
    console.log('Entry:', response.result.node);
    await client.disconnect();
}

getEntry();
```

#### xrpl-py

#### xrpl-py example

```python
from xrpl.clients import JsonRpcClient
from xrpl.models.requests import LedgerEntry

client = JsonRpcClient("https://shared.eu-central-1.getblock.io/<ACCESS_TOKEN>")
request = LedgerEntry(account_root="rN7n7otQDd6FczFgLdSqtcsAUxDkw6fzRH")
response = client.request(request)
print(response.result)
```
