Skip to main content

List all entities

Index#

In order to get all entities, all we have to do is send a GET request to the collections path.

If you wanted to get all todos, the request would look like this:

Listing all todos
GET /api/todos

Pagination#

Pagination is enabled by default on all of your Architect entities, with a default page size of 20. To change the page size when listing entities, send a PER_PAGE header along with your request.

note

Maximum page size is 100. Enterprise users can change this.

In the response headers of your GET request, you will receive a TOTAL_PAGES value. To get a specific page, just add a PAGE header.

An example request would look like this:

Listing todos with pagination
const myHeaders = new Headers();
myHeaders.append("PAGE", "6");
myHeaders.append("PER_PAGE", "2");
const requestOptions = {
method: 'GET',
headers: myHeaders
};
fetch("https://your_app_id.essentialz.cloud/api/todos", requestOptions)
.then(response => response.text())
.then(result => console.log(result))
.catch(error => console.log('error', error));
An example response
[
{
"title": "Get milk",
"id": "56ccb590-45a9-4c8f-8bde-2c89d731d4be",
"created_at": "2021-07-21 15:25:07 UTC",
"updated_at": "2021-08-19 15:25:07 UTC"
},
{
"title": "Create an app using Architect",
"id": "87af6b75-485e-4262-8031-0ee2784213b8",
"created_at": "2021-06-03 21:01:34 UTC",
"updated_at": "2021-06-03 15:11:55 UTC"
}
]

Queries & Filters#

Querying with Architect is easy as 1-2-3. To query our todos by title, we would simply pass a title query parameter with the GET request.

More complex queries can be represented as an object, which can be stringified into a query string. We recommend using this package and it's stringify method for that purpose.

Contains filter#

If we wanted to get all todos that contain the word milk in their title, our parameters would look like this:

?title[_contains]=milk

Min / max filter#

Let's say we wanted to filter our todos even more:

?title[_contains]=milk&created_at[_min]=2021-01-01&created_at[_max]=2021-01-02

Nested fields#

Filtering by a nested field is a breeze:

?details[assignee][_contains]=John

Array contains filter#

Say we want to filter only the todos that have "groceries" and "apples" categories. We would accomplish that using the _arr_contains filter.

?categories[_arr_contains]=groceries

And / or operations#

In a more complex scenario, we can also use the _or and _and operations.

In this example, we'll try to fetch todos that are either named Buy milk, or are named Try Architect and assigned to anyone named John. The query, represented in JSON format, would look like this:

?_or[name]=Buy%20milk&_or[][_and[][name]]=Try%20Architect&_or[][_and[][assignee[name[_contains]]]=John