Odoo ERP

Odoo API Integration: XML-RPC, JSON-RPC and Auth Basics

A practical guide to Odoo API integration: how authentication, XML-RPC and JSON-RPC calls work, and the patterns that keep external systems reliably in sync.

Tech After Me CEOCEO & Odoo ConsultantPublished 6 min read
Share
Odoo API Integration: XML-RPC, JSON-RPC and Auth Basics
On this page

Every Odoo implementation eventually needs to talk to something outside Odoo. A warehouse scanner, a marketplace, a payment gateway, a legacy accounting tool, or an internal dashboard. That conversation almost always happens through Odoo API integration. The mechanics are simpler than most people expect once you have done it a few times.

This is a practitioner's walkthrough, not a full reference. We cover the two protocols Odoo exposes, how authentication actually works, which endpoints you will call most often, and the patterns that separate an integration that survives production traffic from one that breaks the first time a network hiccups.

Odoo API integration: XML-RPC and JSON-RPC are two doors to the same room

Odoo exposes its external API through two protocols that both land on the same server-side logic: XML-RPC and JSON-RPC. Neither is newer or more "official" than the other. They are two serialization formats wrapped around the same remote procedure calls.

  • XML-RPC sends requests as XML payloads. Python's standard library ships with an xmlrpc.client module, so this is often the fastest path from a Python script with zero extra dependencies. PHP, Ruby and most mature languages have mature XML-RPC clients too.
  • JSON-RPC sends requests as JSON over HTTP POST. If your integration already lives in a JavaScript, Node.js or mobile stack where JSON is the native data format, this usually feels more natural and skips an XML parsing step.

Both protocols let you call the same three groups of operations: authenticate, read metadata about models and fields, and run standard CRUD-style operations (search, read, create, write, unlink) on any model you can access. There is no separate "Odoo REST API" product. What people call the Odoo API is this RPC layer, sometimes wrapped by a custom controller when a project wants cleaner REST-style URLs.

Authentication for Odoo API integration: get this right before anything else

Every call to the Odoo API needs three things: the database name, a user, and a credential. In recent Odoo versions this credential should be an API key, generated per user from their preference settings, rather than their interactive login password.

We treat the integration user as its own identity, separate from any human's login:

  1. Create a dedicated user for the integration (for example, [email protected]).
  2. Generate an API key for that user and store it in a secrets manager or environment variable, never in source control.
  3. Assign that user only the access rights and record rules it needs. Typically a narrow group that can read and write specific models, not the full Settings or Administration group.
  4. Authenticate once per session to get a uid, then pass the uid and API key on every subsequent call.

A common mistake is reusing a real employee's login for the integration. That breaks the moment the password rotates or the account is deactivated during offboarding. A dedicated service account avoids that failure mode entirely. It also makes the audit trail (chatter, write_date, create_uid) show clearly which changes came from the integration versus a human.

Endpoints and calls you will actually use

In practice, most integration work uses a small handful of calls on the execute_kw endpoint:

OperationTypical use
search_readPull a filtered, paginated list of records with only the fields you need
readFetch full field values for known record IDs
createPush a new record, such as a sales order or a stock move
writeUpdate existing fields, such as marking an order as shipped
unlinkDelete a record, used sparingly and usually guarded by access rights
fields_getIntrospect which fields exist on a model, useful during initial mapping

A pattern worth adopting from day one: never call search and then read separately when search_read can do both in one round trip. For high-volume syncs, this alone can cut your request count meaningfully. Each RPC call carries authentication and routing overhead on top of the actual query.

For write-heavy integrations such as order creation from an e-commerce platform, it helps to read our Shopify connector notes on sync design. The same questions apply to any external system, not just Shopify: what counts as a duplicate, and which side wins on conflict.

Designing Odoo API integration for reliability, not just the happy path

A script that correctly creates a sales order once, in testing, is not an integration. It is a proof of concept. Production integrations fail in ways that never show up in a demo. The network times out mid-request, two systems try to update the same record at once, or a required field changes because someone edited a workflow without telling the integration team. We design around those cases up front.

  • Idempotency. Give every inbound create request a unique external reference, stored in a custom field, and check for it before inserting. Without this, a retried webhook or a timed-out call that actually succeeded server-side will create duplicate records.
  • Retry with backoff. Transient errors (connection resets, momentary 500s) deserve a retry with exponential backoff, not an immediate alert. Validation errors, such as a required field missing or a currency mismatch, should fail fast and log clearly instead of retrying forever.
  • Batching with limits. search_read and create both accept lists, so batch records where the API allows it, but respect a sane batch size. Pushing thousands of records in a single call risks a timeout that rolls back the entire batch instead of just the one bad row.
  • Logging on both sides. Keep a log of what was sent, when, and what came back. Ideally in a table the integration owns, not scattered across application server logs that rotate out after a few days.
  • Versioned field mapping. Document which Odoo field maps to which external field in a single source of truth, such as a spreadsheet or a config file. This mapping is the first thing that breaks during an Odoo upgrade or a schema change on the other side.

The trade-off worth naming honestly: building an integration this way takes longer than a quick script that calls create directly from a cron job. For a one-off internal tool moving a few dozen records a day, that overhead may not be worth it. For anything customer-facing, anything financial, or anything running unattended at volume, skipping these patterns almost always costs more later. Expect duplicate orders, silent failures and debugging sessions at odd hours.

Where custom controllers fit into Odoo API integration

Sometimes the standard CRUD calls are not enough. You need a workflow that spans multiple models in one transaction, or you want a cleaner URL structure for a partner who expects REST conventions. In those cases we build a thin custom controller inside a module, exposing a specific endpoint (for example, /api/v1/orders) that internally calls the same ORM methods XML-RPC and JSON-RPC would use, but wrapped in your own validation and response format.

This is one of the few places we deviate from our usual configure-first, code-last rule, because authentication scoping and payload shaping for an external partner genuinely requires code. Even then, we keep the controller as a thin wrapper around standard ORM calls rather than rewriting business logic, so core upgrade paths stay clean.

Check access rights before you debug the API

A surprising share of "the API is not working" tickets turn out to be access rights, not API bugs. If the integration user cannot see a field due to a group restriction, or a record rule filters it out of search_read results silently, the call still returns 200 with an empty or partial result. No error is thrown. Before debugging the RPC layer itself, check the user's groups and any record rules that might be scoping its visibility. This single check saves more integration debugging time than almost anything else on this list.

One limitation worth stating plainly: the external API exposes whatever the ORM exposes. Any custom validation you add in Python, such as @api.constrains or ondelete methods, also runs on API-driven writes. If a constraint assumes a human filled a form field-by-field in a particular order, an API call that sets multiple fields in one shot can trip that constraint in ways the UI never would. Testing write operations from the actual integration client, not just from the Odoo UI, catches this before it reaches production.

If you are scoping a new integration, whether a marketplace feed, a custom mobile app, or a legacy system migration, our team handles the authentication setup, endpoint mapping and reliability patterns described here as a fixed-scope phase. See our Odoo API integration services for how we structure that work.

Share

Frequently asked questions

Should I use XML-RPC or JSON-RPC for Odoo API integration?

Both reach the same business logic, so the choice is mostly about your client library and payload size. JSON-RPC tends to be easier to work with from modern web stacks since most languages already have strong JSON support, while XML-RPC libraries are built into Python and PHP by default.

Does Odoo API integration require Enterprise edition?

No. The external API is available in Community and Enterprise alike, because it is part of the core server, not a paid module. What differs between editions is which business modules and fields you can call, not the API mechanism itself.

How do I authenticate against the Odoo API securely?

Use a dedicated integration user with its own API key rather than a shared login and password. Scope that user's access rights and record rules tightly, rotate the key on a schedule, and never embed it directly in client-side code.

Can I call the Odoo API without writing a custom module?

Yes, for most standard reads, creates, updates and searches on existing models. A custom module is only needed when you must add new fields, expose a workflow that is not already a model method, or build a dedicated REST-style controller.

What is the biggest cause of unreliable Odoo integrations?

Treating every external call as if it always succeeds. Network timeouts, concurrent edits and validation errors are normal, so integrations need retry logic, idempotency keys and logging, not just a one-time working script.

Sources

About the author

Tech After Me CEO

CEO & Odoo Consultant

The CEO of Tech After Me implements, customizes and supports Odoo ERP and builds web, mobile and data products for companies in Thailand, the USA and India.

More from this author

Keep reading

Put what you read into practice

The team writing these guides is the same team that ships them. Tell us what you are working on.

Get new articles in your inbox

Get new articles in your inbox

Odoo guides and IT news that matter to your business. At most one email a week.