List Records¶
Records can be listed and filtered via search(). It takes a mandatory domain filter (possibly empty), and returns the database identifiers of all records matching the filter.
-
GET
/restapi/1.0/object/{object_name}/search
¶ Request:
GET /restapi/1.0/object/res.partner/search?domain=[('is_company','=',True),('customer','=',True)] HTTP/1.1 Host: {your_Odoo_server_url}
Response:
HTTP/1.1 200 OK { 'Partner': [ 7, 18, 12, 10, 17, 19, 8, 31, 26, 16, 13, 20, 30, 22, 29, 15, 23, 28, 74 ] }
Query Parameters: - domain – A search domain. Use an empty list to match all records.
- offset – OPTIONAL. Number of results to ignore (default: none)
- limit – OPTIONAL. Maximum number of records to return (default: all)
- order – OPTIONAL. Sort string
- count – OPTIONAL. if True, only counts and returns the number of matching records (default: False)
Request Headers: - Accept – the response content type depends on Accept header
- Authorization – The OAuth protocol parameters to authenticate.
Response Headers: - Content-Type – this depends on Accept header of request
Status Codes: - 200 OK – no error
- 404 Not Found – there’s no resource
- 401 Unauthorized – authentication failed
- 403 Forbidden – if any error raise
Pagination¶
By default a restapi/1.0/object/{object_name}/search
will return the ids of all records matching the condition, which may be a huge number. offset
and limit
parameters are available to only retrieve a subset of all matched records.
Request:
GET /restapi/1.0/object/res.partner/search?domain=[('is_company','=',True),('customer','=',True)]&offset=10&limit=5 HTTP/1.1 Host: {your_Odoo_server_url}Response:
HTTP/1.1 200 OK { 'Partner': [ 13, 20, 30, 22, 29 ] }