External API
Read and write a workspace's data from another system. The API speaks XML-RPC and JSON-RPC over your workspace URL.
Authenticate
Authenticate with a workspace user's credentials (use a dedicated integration user, not a person's login). You get back a user id to use on subsequent calls.
Call models
Every public ORM method is callable: search, read, search_read, create,
write, unlink, and your own model methods.
import xmlrpc.client
url = "https://acme.your-domain"
db = "acme"
uid = 2 # from authentication
password = "..." # integration user's key
models = xmlrpc.client.ServerProxy(f"{url}/xmlrpc/2/object")
# Read open leads
ids = models.execute_kw(db, uid, password,
"my.lead", "search", [[["stage", "=", "new"]]])
records = models.execute_kw(db, uid, password,
"my.lead", "read", [ids], {"fields": ["name", "expected"]})
# Create one
new_id = models.execute_kw(db, uid, password,
"my.lead", "create", [{"name": "Globex"}])
Practical notes
- One database per workspace. The
dbis the workspace's database name (its subdomain). - Use an integration user with only the access rights it needs.
- Rate and batch. Prefer
search_readoversearch+read, and batch writes.
Related
- The methods you're calling are the ORM.
- For in-browser calls, use the
ormservice in The web framework.
Need a hand with this? company@everjust.co — a human answers.