GET
Model records:
GET /api/{model}/
Parameters
-
query (optional):
This parameter is used to dynamically select fields to include in a response. For example, if we want to select id
and name
fields from res.users
model here is how we would do it.
GET /api/res.users/?query={id, name}
{
"count": 2,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 2,
"name": "Administrator"
},
{
"id": 6,
"name": "Grey Goose"
}
]
}
For nested records, for example, if we want to select id
, name
and company_id
fields from res.users
model, but under company_id
we want to select name
field only. here is how we would do it.
GET /api/res.users/?query={id, name, company_id{name}}
{
"count": 2,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 2,
"name": "Administrator",
"company_id": {
"name": "ABC International Limited"
}
},
{
"id": 6,
"name": "Grey Goose",
"company_id": {
"name": "ABC Family Trust"
}
}
]
}
For nested iterable records, for example, if we want to select id
, name
and related_products
fields from product.template
model, but under related_products
we want to select name
field only. here is how we would do it.
GET /api/product.template/?query={id, name, related_products{name}
{
"count": 2,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 16,
"name": "Corporate Services",
"related_products": [
{"name": "Provision of Corporate Director"},
{"name": "Registered Office"}
]
},
{
"id": 18,
"name": "Trustee Services",
"related_products": [
{"name": "Provision of Trustees"},
{"name": "Tax Compliance"},
{"name": "Deed of Amendment"}
]
}
]
}
If you want to fetch all fields except a few you can use the exclude(-) operator. For example in the case above if we want to fetch all fields except name
field, here is how we could do it
GET /api/product.template/?query={-name}
{
"count": 3,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 1,
... // All fields except name
},
{
"id": 2
... // All fields except name
}
...
]
}
There is also a wildcard(*) operator which can be used to fetch all fields, Below is an example which shows how you can fetch all product's fields but under related_products
field get all fields except id
.
GET /api/product.template/?query={*, related_products{-id}}
{
"count": 3,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 1,
"name": "Provision of Company Secretary",
"related_products"{
"name": "Company Secretarial",
... // All fields except id
}
... // All fields
},
...
]
}
If you don't specify the query parameter all fields will be returned.
-
filter (optional):
This is used to filter out data returned. For example if we want to get all products with id ranging from 60 to 70, here's how we would do it.
GET /api/product.template/?query={id, name}&filter=[["id", ">", 60], ["id", "<", 70]]
{
"count": 3,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 67,
"name": "Filing annual returns with registrar"
},
{
"id": 69,
"name": "Business Risk Assessment"
}
]
}
-
page_size (optional) & page (optional):
These two allow us to do pagination. Hre page_size is used to specify the number of records on a single page and page is used to specify the current page. For example, if we want our page_size to be 5 records and we want to fetch data on page 3 here is how we would do it.
GET /api/product.template/?query={id, name}&page_size=5&page=3
{
"count": 5,
"prev": 2,
"current": 3,
"next": 4,
"total_pages": 15,
"result": [
{"id": 141, "name": "Registered office and registered agent"},
{"id": 114, "name": "UK Property tax compliance"},
{"id": 128, "name": "Insurance review"},
{"id": 111, "name": "UK 10 year tax"},
{"id": 62, "name": "External counsel - review of deeds"}
]
}
Note: prev
, current
, next
and total_pages
shows the previous page, current page, next page, and the total number of pages respectively.
-
limit (optional):
This is used to limit the number of results returned on a request regardless of pagination. For example
GET /api/product.template/?query={id, name}&limit=3
{
"count": 3,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{"id": 16, "name": "Provision of Director (natural person)"},
{"id": 18, "name": "Fiscal representative"},
{"id": 95, "name": "CRS Returns"}
]
}
query (optional):
This parameter is used to dynamically select fields to include in a response. For example, if we want to select id
and name
fields from res.users
model here is how we would do it.
GET /api/res.users/?query={id, name}
{
"count": 2,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 2,
"name": "Administrator"
},
{
"id": 6,
"name": "Grey Goose"
}
]
}
For nested records, for example, if we want to select id
, name
and company_id
fields from res.users
model, but under company_id
we want to select name
field only. here is how we would do it.
GET /api/res.users/?query={id, name, company_id{name}}
{
"count": 2,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 2,
"name": "Administrator",
"company_id": {
"name": "ABC International Limited"
}
},
{
"id": 6,
"name": "Grey Goose",
"company_id": {
"name": "ABC Family Trust"
}
}
]
}
For nested iterable records, for example, if we want to select id
, name
and related_products
fields from product.template
model, but under related_products
we want to select name
field only. here is how we would do it.
GET /api/product.template/?query={id, name, related_products{name}
{
"count": 2,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 16,
"name": "Corporate Services",
"related_products": [
{"name": "Provision of Corporate Director"},
{"name": "Registered Office"}
]
},
{
"id": 18,
"name": "Trustee Services",
"related_products": [
{"name": "Provision of Trustees"},
{"name": "Tax Compliance"},
{"name": "Deed of Amendment"}
]
}
]
}
If you want to fetch all fields except a few you can use the exclude(-) operator. For example in the case above if we want to fetch all fields except name
field, here is how we could do itGET /api/product.template/?query={-name}
{
"count": 3,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 1,
... // All fields except name
},
{
"id": 2
... // All fields except name
}
...
]
}
There is also a wildcard(*) operator which can be used to fetch all fields, Below is an example which shows how you can fetch all product's fields but under related_products
field get all fields except id
.
GET /api/product.template/?query={*, related_products{-id}}
{
"count": 3,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 1,
"name": "Provision of Company Secretary",
"related_products"{
"name": "Company Secretarial",
... // All fields except id
}
... // All fields
},
...
]
}
If you don't specify the query parameter all fields will be returned.
filter (optional):
This is used to filter out data returned. For example if we want to get all products with id ranging from 60 to 70, here's how we would do it.
GET /api/product.template/?query={id, name}&filter=[["id", ">", 60], ["id", "<", 70]]
{
"count": 3,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{
"id": 67,
"name": "Filing annual returns with registrar"
},
{
"id": 69,
"name": "Business Risk Assessment"
}
]
}
page_size (optional) & page (optional):
These two allow us to do pagination. Hre page_size is used to specify the number of records on a single page and page is used to specify the current page. For example, if we want our page_size to be 5 records and we want to fetch data on page 3 here is how we would do it.
GET /api/product.template/?query={id, name}&page_size=5&page=3
{
"count": 5,
"prev": 2,
"current": 3,
"next": 4,
"total_pages": 15,
"result": [
{"id": 141, "name": "Registered office and registered agent"},
{"id": 114, "name": "UK Property tax compliance"},
{"id": 128, "name": "Insurance review"},
{"id": 111, "name": "UK 10 year tax"},
{"id": 62, "name": "External counsel - review of deeds"}
]
}
Note: prev
, current
, next
and total_pages
shows the previous page, current page, next page, and the total number of pages respectively.
limit (optional):
This is used to limit the number of results returned on a request regardless of pagination. For example
GET /api/product.template/?query={id, name}&limit=3
{
"count": 3,
"prev": null,
"current": 1,
"next": null,
"total_pages": 1,
"result": [
{"id": 16, "name": "Provision of Director (natural person)"},
{"id": 18, "name": "Fiscal representative"},
{"id": 95, "name": "CRS Returns"}
]
}
Model record:
GET /api/{model}/{id}
Parameters
-
query (optional):
Here query parameter works exactly the same as explained before except it selects fields on a single record. For example
GET /api/product.template/95/?query={id, name}
{
"id": 95,
"name": "Retirement of Trusteeship"
}
query (optional):
Here query parameter works exactly the same as explained before except it selects fields on a single record. For example
GET /api/product.template/95/?query={id, name}
{
"id": 95,
"name": "Retirement of Trusteeship"
}