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

# Get Agent Count

> Get the total number of agents registered in the ERC-8004 Identity Registry

## Overview

Returns the total number of AI agents minted in the [ERC-8004](https://eips.ethereum.org/EIPS/eip-8004) Identity Registry on Base. This is useful for understanding the size of the registry and for paginating through the full agent list.

<Info>
  This is a free endpoint (0 Cred Units). It reads directly from the on-chain Identity Registry contract on Base.
</Info>

## Authentication

| Method       | Header                               | Cost         |
| ------------ | ------------------------------------ | ------------ |
| API Token    | `Authorization: Bearer YOUR_API_KEY` | 0 Cred Units |
| x402 Payment | `X-PAYMENT: <signed_payment>`        | Free         |

## Response

<ResponseField name="total" type="integer">
  Total number of agents currently registered in the Identity Registry
</ResponseField>

<RequestExample>
  ```bash cURL theme={null}
  curl -X GET "https://api.credprotocol.com/api/v2/agents/count" \
    -H "Authorization: Bearer YOUR_API_KEY"
  ```

  ```javascript JavaScript theme={null}
  const response = await fetch('https://api.credprotocol.com/api/v2/agents/count', {
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY'
    }
  });

  const data = await response.json();
  console.log(`Total agents: ${data.total}`);
  ```

  ```python Python theme={null}
  import requests

  response = requests.get(
      'https://api.credprotocol.com/api/v2/agents/count',
      headers={'Authorization': 'Bearer YOUR_API_KEY'}
  )

  data = response.json()
  print(f"Total agents: {data['total']}")
  ```
</RequestExample>

<ResponseExample>
  ```json 200 theme={null}
  {
    "total": 42
  }
  ```

  ```json 502 theme={null}
  {
    "detail": "Failed to read from Identity Registry contract"
  }
  ```
</ResponseExample>

## Performance

* **Response Time**: Typically under 1 second
* **Data Source**: On-chain `totalSupply()` call to the Identity Registry on Base (chain 8453)
