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

# Authentication

> Connect to Odoo 18 with JSON-RPC / XML-RPC

Odoo’s external API uses **JSON-RPC** or **XML-RPC**. Prefer JSON-RPC for new integrations.

Official reference: [Odoo 18 External API](https://www.odoo.com/documentation/18.0/developer/reference/external_api.html).

## Credentials you need

| Value | Where |
| - | - |
| `url` | Your Odoo base URL, e.g. `https://mycompany.odoo.com` |
| `db` | Database name |
| `username` | User login (email) |
| `password` | User password **or** an [API key](https://www.odoo.com/documentation/18.0/developer/reference/external_api.html#api-keys) |

Create an API key in Odoo under the user preferences. Prefer API keys over the account password.

The user must have **read** (and optionally write) access on `real_estate.real_estate`.

## JSON-RPC authenticate

```python theme={null}
import json
import urllib.request

url = "https://YOUR_HOST"
db = "YOUR_DB"
username = "user@example.com"
password = "YOUR_API_KEY"  # or password

payload = {
    "jsonrpc": "2.0",
    "method": "call",
    "params": {
        "service": "common",
        "method": "authenticate",
        "args": [db, username, password, {}],
    },
    "id": 1,
}

req = urllib.request.Request(
    f"{url}/jsonrpc",
    data=json.dumps(payload).encode(),
    headers={"Content-Type": "application/json"},
)
uid = json.load(urllib.request.urlopen(req))["result"]
assert uid, "Authentication failed"
```

`uid` is an integer. Pass `db`, `uid`, and `password` on every later `execute_kw` call.

## XML-RPC (alternative)

```python theme={null}
import xmlrpc.client

url = "https://YOUR_HOST"
db = "YOUR_DB"
username = "user@example.com"
password = "YOUR_API_KEY"

common = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/common")
uid = common.authenticate(db, username, password, {})
models = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/object")
```

## Next

[Pull properties with `search_read`](/docs/guides/pull-properties)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.