Odoo Standard RESTful JSON API


Background Image

How It Works:

By defining a standard structure for API requests and responses, this module promotes consistency and ease of use.

Each request includes a various methods such as Search, Search Read, Read, Check Access Right, & Create etc, that defines the action to be performed on the resource. The server’s response typically contains the requested data in JSON format, along with an HTTP status code to indicate success or failure.

Standard REST Json API Request’s Overview:

POST

{domain[:port]}/{endpoint}/{model}/{method}

  • This is the main query parameters which is mandatory to write when you are working with APIs.
  • Use “HTTP POST Method” to send specific data.
  • Domain is specified your wesite’s domain address. The port number is optional.
  • Endpoint is the specific path within the API that identifies the particular resource or action.
    This part of the URL tells the server what type of operation is being requested.
  • Model is Odoo’s technical name of entities and also known as model name, record’s model or
    entities. You can identify it from the URL shown below.
  • Method specifies the type of action being performed on the server.
  • Domain Image

  • Headers in an API request are key-value pairs sent between the client and the server, providing
    additional information about the request or the client itself. They are part of the HTTP protocol and can
    carry various types of metadata.
  • Add “Content-Type” and “x-api-key” keys with their specific values. REST API’s media
    type designation is “application/json“. Add this in Content-Type’s value field and also add your
    API Key.
  • Rest JSON API Headers

Search Read:

POST

http://localhost:8016/api-rest-json/res.partner/search_read

See the Example with Query & Output:

Example: This query combines search and read operations for res.partner records in a local Odoo instance via the /api-rest-json/res.partner/search_read endpoint. It retrieves records that match specified criteria and returns their details in a single request.

Query & Output
Rest JSON Search Read Request

Query:
*** python ***

import requests
import json

url = "http://localhost:8016/api-rest-json/res.partner/search_read"

payload = json.dumps({
"args": [
    [
    [
        "is_company",
        "=",
        True
    ]
    ]
],
"kwargs": {
    "fields": [
    "name",
    "country_id",
    "comment",
    "is_company"
    ],
    "limit": 5
}
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR-API-KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Search Count:

POST

http://localhost:8016/api-rest-json/res.partner/search_count

See the Example with Query & Output:

Example: This query returns the count of res.partner records in a local Odoo instance via the /api-rest-json/res.partner/search_count endpoint.

Query & Output
Rest JSON Search Count Request

Query:
*** python ***

import requests
import json

url = "http://localhost:8016/api-rest-json/res.partner/search_count"

payload = json.dumps({
"args": [
    [
    [
        "is_company",
        "=",
        True
    ]
    ]
],
"kwargs": {}
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR-API-KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Read:

POST

http://localhost:8016/api-rest-json/res.partner/read

See the Example with Query & Output:

Example: This query retrieves details of res.partner records from a local Odoo instance via the /api-rest-json/res.partner/read endpoint.

Query & Output
Rest JSON Read Request

Query:
*** python ***

import requests
import json

url = "http://localhost:8016/api-rest-json/res.partner/read"

payload = json.dumps({
"args": [
    [
    14,
    10,
    11
    ]
],
"kwargs": {
    "fields": [
    "name",
    "country_id",
    "comment",
    "is_company"
    ]
}
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR-API-KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Read Group:

POST

http://localhost:8016/api-rest-json/res.partner/read_group

See the Example with Query & Output:

Example:
This query retrieves grouped data for res.partner records in a local Odoo instance via the /api-rest-json/res.partner/read_group endpoint. It allows grouping records based on specified fields.

Query & Output
Rest JSON Read Group Request

Query:
*** python ***

import requests
import json

url = "http://localhost:8016/api-rest-json/res.partner/read_group"

payload = json.dumps({
"args": [
    [
    [
        "is_company",
        "=",
        False
    ]
    ]
],
"kwargs": {
    "fields": [
    "name",
    "country_id",
    "comment",
    "is_company"
    ],
    "groupby": "country_id"
}
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR-API-KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Create:

POST

http://localhost:8016/api-rest-json/res.partner/create

See the Example with Query & Output:

Example: This query creates a new res.partner record in a local Odoo instance via the /api-rest-json/res.partner/create endpoint. It uses the POST method to send the necessary data for the new record.

Query & Output
Rest JSON Create Request

Query:
*** python ***

import requests
import json

url = "http://localhost:8016/api-rest-json/res.partner/create"

payload = json.dumps({
"args": [
    {
    "name": "Sample Partner",
    "email": "sample-partner@example.com"
    }
],
"kwargs": {}
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR-API-KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Write:

POST

http://localhost:8016/api-rest-json/res.partner/write

See the Example with Query & Output:

Example: This query updates existing res.partner records in a local Odoo instance via the /api-rest-json/res.partner/write endpoint. It uses the POST method to send updated data for specific records, modifying their fields.

Query & Output
Rest JSON Write Request

Query:
*** python ***

import requests
import json

url = "http://localhost:8016/api-rest-json/res.partner/write"

payload = json.dumps({
"args": [
    [
    49
    ],
    {
    "name": "Sample Partner Change",
    "email": "sample-partner-change@example.com"
    }
],
"kwargs": {}
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR-API-KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Fields Get:

POST

http://localhost:8016/api-rest-json/res.partner/fields_get

See the Example with Query & Output:

Example: This query retrieves the field definitions for the res.partner model in a local Odoo instance via the /api-rest-json/res.partner/fields_get endpoint. It provides information about the fields, such as their types, labels, and other properties.

Query & Output
Rest JSON Fields Get Request

Query:
*** python ***

import requests
import json

url = "http://localhost:8016/api-rest-json/res.partner/fields_get"

payload = json.dumps({
"args": [],
"kwargs": {
    "attributes": [
    "string",
    "help",
    "type"
    ]
}
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR-API-KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Check Access Rights:

POST

http://localhost:8016/api-rest-json/res.partner/check_access_rights

See the Example with Query & Output:

Example: This query checks the access rights for the res.partner model in a local Odoo instance via the /api-rest-json/res.partner/check_access_rights endpoint. It verifies whether the user has the necessary permissions (such as create, read, write, delete) for the specified model.

Query & Output
Rest JSON Check Access Rights Request

Query:
*** python ***

import requests
import json

url = "http://localhost:8016/api-rest-json/res.partner/check_access_rights"

payload = json.dumps({
"args": [
    "create"
],
"kwargs": {}
})
headers = {
'Content-Type': 'application/json',
'x-api-key': 'YOUR-API-KEY'
}

response = requests.request("POST", url, headers=headers, data=payload)

print(response.text)

Swagger Documentation


Document View Setting 2
Document View Setting 1

Services EKIKA Provides

EKIKA is your destination for expert Odoo ERP implementation and customization. We pride ourselves on building reliable, trust-based partnerships that give you full transparency and control over your business processes.

With over 12 years of experience, we can assist you with eCommerce platforms, production planning, point-of-sale systems, managing inventory adjustments, and providing advanced field worker tracking solutions to optimize your workflows and boost operational efficiency.

Ekika Odoo Implementation

Implementation

Utilise Odoo ERP tailored for your business needs for smooth operations.

Ekika Odoo Customization

Customization

Personalized adjustments to Odoo modules for seamless management.

Ekika Odoo Support

Support

Ongoing assistance and maintenance to optimize your Odoo system’s performance.

Are you struggling with disorganized operations, high operational costs, or lack of transparency in your processes? What sets us apart is our commitment to personalized solutions tailored to your unique business needs and our proactive support, ensuring seamless integration and ongoing success.

Would you like to explore Odoo ERP for your business? Schedule a free consultation with EKIKA today!

You must log in to submit a review.