# Identity API (/docs/identity/identity-api)

The Identity API is two `GET` endpoints that turn a swop.id into the data you need to show and pay a person: their display name, avatar, EVM address and Solana address.

<Callout title="No key needed">
Both endpoints are public and read-only. They accept requests from any origin (CORS is open for `GET`), so you can call them straight from a browser.
</Callout>

**Base URL**

```text
https://apps.apiswop.co/api/v5/identity
```

## Look up an exact swop.id [#look-up-an-exact-swopid]

`GET /lookup?handle=<swop.id>`

Use this when you already know the full name, for example to render a profile card or to check that a name exists.

| Query parameter | Required | Description |
|---|---|---|
| `handle` | Yes | The full swop.id, including `.swop.id` (for example `maya.swop.id`). Case-insensitive. `maya` on its own won't match. |

<Tabs items={['curl', 'Node', 'Python']}>
<Tab value="curl">
```bash
curl "https://apps.apiswop.co/api/v5/identity/lookup?handle=maya.swop.id"
```
</Tab>
<Tab value="Node">
```js
const url = new URL('https://apps.apiswop.co/api/v5/identity/lookup');
url.searchParams.set('handle', 'maya.swop.id');

const res = await fetch(url);
const body = await res.json();
if (!res.ok) throw new Error(body.message);

console.log(body.data.evmAddress, body.data.solanaAddress);
```
</Tab>
<Tab value="Python">
```python
import requests

res = requests.get(
    "https://apps.apiswop.co/api/v5/identity/lookup",
    params={"handle": "maya.swop.id"},
    timeout=10,
)
body = res.json()
res.raise_for_status()
print(body["data"]["evmAddress"], body["data"]["solanaAddress"])
```
</Tab>
</Tabs>

**Response** `200 OK`

```json
{
  "state": "success",
  "data": {
    "handle": "maya.swop.id",
    "name": "Maya Chen",
    "avatar": "https://res.cloudinary.com/.../avatar.jpg",
    "primary": true,
    "evmAddress": "0x1111111111111111111111111111111111111111",
    "solanaAddress": "7xKXtg2CW87d97TXJSDpbD5jBkheTqA83TZRuJosgAsU"
  }
}
```

## Search by handle or name [#search-by-handle-or-name]

`GET /resolve?q=<text>&limit=<n>`

Use this for a search-as-you-type picker ("send to…", "choose a validator…"). It matches the text anywhere in the handle **or** the display name, case-insensitive.

| Query parameter | Required | Description |
|---|---|---|
| `q` | Yes | At least 2 characters. |
| `limit` | No | 1 to 20. Defaults to 8. |

<Tabs items={['curl', 'Node', 'Python']}>
<Tab value="curl">
```bash
curl "https://apps.apiswop.co/api/v5/identity/resolve?q=maya&limit=5"
```
</Tab>
<Tab value="Node">
```js
const url = new URL('https://apps.apiswop.co/api/v5/identity/resolve');
url.searchParams.set('q', 'maya');
url.searchParams.set('limit', '5');

const { data } = await (await fetch(url)).json();
for (const person of data) console.log(person.handle, person.name);
```
</Tab>
<Tab value="Python">
```python
import requests

res = requests.get(
    "https://apps.apiswop.co/api/v5/identity/resolve",
    params={"q": "maya", "limit": 5},
    timeout=10,
)
for person in res.json()["data"]:
    print(person["handle"], person["name"])
```
</Tab>
</Tabs>

**Response** `200 OK`: `data` is an array of the same objects `/lookup` returns. An empty array means no match.

## The identity object [#the-identity-object]

| Field | Type | Description |
|---|---|---|
| `handle` | string | The full swop.id, for example `maya.swop.id`. |
| `name` | string | Display name. May be empty. |
| `avatar` | string | Avatar image URL. May be empty; always check before rendering. |
| `primary` | boolean | `true` if this is the account's primary swop.id. One account can hold several. |
| `evmAddress` | string \| null | The EVM address (Ethereum, Base, Polygon, Arbitrum and other EVM chains). |
| `solanaAddress` | string \| null | The Solana address, or `null` if none is set. |

Addresses are stored by SLIP-44 coin type, the same convention ENS uses: `60` for EVM and `501` for Solana.

## Errors [#errors]

Errors return a non-2xx status with a JSON body:

```json
{ "success": false, "status": "fail", "message": "swop.id not found", "correlationId": "1793287805039" }
```

| Status | When |
|---|---|
| `400` | `handle` is missing, or `q` is shorter than 2 characters. |
| `404` | `/lookup` found no swop.id with that exact handle. |
| `429` | Rate limit reached. |

Quote the `correlationId` if you contact support about a failed request.

## Rate limits [#rate-limits]

100 requests per 15 minutes per IP address. The standard `RateLimit-Limit`, `RateLimit-Remaining` and `RateLimit-Reset` headers tell you where you stand. Cache results for a few minutes in your app rather than calling on every render.

## Before you send money [#before-you-send-money]

The Identity API is the right tool for finding and displaying people. Before you **send funds** to a name, re-resolve it at payment time and show the resolved address to the payer. For the strongest guarantee, resolve through ENS, which is verified against the `swop.id` resolver contract on Ethereum. See [Resolve with ENS](/docs/identity/resolve-with-ens).
