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

# Get Loan

> Read a loan directly from the market contract

Returns live loan state by numeric loan ID, read from the contract with no database involvement. Use this when you need authoritative figures for a payoff quote, a health check, or a liquidation decision.

## Path Parameters

<ParamField path="marketId" type="string" required>Market ID.</ParamField>
<ParamField path="loanId" type="integer" required>On-chain loan ID. Must be a positive integer.</ParamField>

## Response Fields

<ResponseField name="data" type="object">
  <Expandable>
    <ResponseField name="loanId" type="string">Loan ID, echoed back.</ResponseField>
    <ResponseField name="borrower" type="string">Borrower address.</ResponseField>
    <ResponseField name="collateralAmount" type="string">Collateral pledged, in collateral token units.</ResponseField>
    <ResponseField name="principal" type="string">Outstanding principal, in borrow asset units.</ResponseField>
    <ResponseField name="accruedInterest" type="string">Interest accrued and unpaid, in borrow asset units.</ResponseField>
    <ResponseField name="healthFactor" type="string">Health factor at 18 decimal places. `1.0` is the liquidation boundary.</ResponseField>
    <ResponseField name="active" type="boolean">Whether the loan is open. `false` once it is repaid, closed, or fully liquidated.</ResponseField>
  </Expandable>
</ResponseField>

<Tip>
  Total payoff is `principal` plus `accruedInterest`. Interest accrues per block, so add a small margin when quoting a full repayment. The contract caps repayment at the actual debt, so a slight overpayment is not transferred.
</Tip>

<RequestExample>
  ```bash cURL theme={null}
  curl "https://api.trusset.org/lending-external-securities/api/positions/{marketId}/loan/5" \
    -H "X-API-Key: trusset_your_key_here"
  ```

  ```typescript TypeScript theme={null}
  const res = await fetch(
    `https://api.trusset.org/lending-external-securities/api/positions/${marketId}/loan/5`,
    { headers: { 'X-API-Key': 'trusset_your_key_here' } }
  );
  const { data } = await res.json();
  const liquidatable = data.active && parseFloat(data.healthFactor) < 1;
  ```
</RequestExample>

<ResponseExample>
  ```json Response theme={null}
  {
    "success": true,
    "data": {
      "loanId": "5",
      "borrower": "0xabc...def",
      "collateralAmount": "1000.000000000000000000",
      "principal": "50000.000000",
      "accruedInterest": "128.750000",
      "healthFactor": "1.842000000000000000",
      "active": true
    }
  }
  ```

  ```json Error - Not Found theme={null}
  {
    "success": false,
    "error": {
      "code": "LOAN_NOT_FOUND",
      "message": "Loan not found"
    }
  }
  ```

  ```json Error - Invalid ID theme={null}
  {
    "success": false,
    "error": {
      "code": "INVALID_LOAN_ID",
      "message": "Valid loan ID required"
    }
  }
  ```
</ResponseExample>
