Skip to content

Basic Object Retrieval

Backendless supports multiple data search and retrieval operations. These include finding an object by its objectId, finding first or last object in the collection or retrieving the entire persisted collection.

Retrieving Data Objects

Method

GET

Endpoint URL

The xxxx.backendless.app is a subdomain assigned to your application. For more information see the Client-side Setup section of this documentation.

Find by ID:

https://xxxx.backendless.app/api/data/<table-name>/<object-id>?loadRelations=<relations> 

Find first:

https://xxxx.backendless.app/api/data/<table-name>/first?loadRelations=<relations>

Find last:

https://xxxx.backendless.app/api/data/<table-name>/last?loadRelations=<relations>

Basic Find (retrieving a collection):

https://xxxx.backendless.app/api/data/<table-name>

where:

Argument                Description
<table-name> name of the table where to search for the object.
<object-id> ID of the object to retrieve. The ID assigned by Backendless in the create object operation.
<relations> a list of related columns to return the values of with the parent object. The values must be separated by comma and then URL-encoded. For example relationA,relationB must be specified in the request as relationA%2CrelationB

Request Headers

user-token:value-of-the-user-token-header-from-login

where:

Argument                Description
user-token Optional header. Contains a value returned by Backendless in a preceding user Login API call. If user-tokenis set in the request, the operation will be executed with the security policy associated with the currently logged in user. This means all permissions associated with the user and roles assigned to the user will be enforced by Backendless.

Request Body:

None

Example

Important

Make sure to replace xxxx in the domain name in the sample requests below to the one assigned to your application.

Find first object:

curl "https://xxxx.backendless.app/api/data/Person/first"

Find last object:

curl "https://xxxx.backendless.app/api/data/Person/last"

Find object by ID:

curl "https://xxxx.backendless.app/api/data/Person/XXXX-XXXX-XXXX-XXXX"

Load Person objects:

curl "https://xxxx.backendless.app/api/data/Person"

Codeless Reference

The data table employees presented below is used throughout all Codeless examples as the main reference:

data_service_example_data_table_basic_object_retrieval

Find First Object

The example below retrieves the first object stored in the "employees" data table.

data_service_get_first_object_from_table

where:

Argument                Description
table name Name of the data table from where the required object is retrieved.
relations Name of the related property to load. For example, if table employees has a relation column homeAddress pointing to an object in the Address table, the value of the parameter would be homeAddress. The syntax allows to add relations of relations. For example, if the same Address table has a relation country pointing to the Country table, then homeAddress.country would instruct the backend to load the related Country object.
relations depth Depth of the relations to include into the response.
properties Names of the properties/columns for which  to load the corresponding values.
exclude properties Names of the properties/columns that should not be included in the response.

The operation has returned the following result:

data_service_example_get_first_object_from_table

Find Last Object

The example below retrieves the last object stored in the "employees" data table.

data_service_get_last_object_from_table

The operation has returned the following result:

data_service_example_get_last_object_from_table

Find Object By ID

Consider the following scenario where you want to retrieve an object associated with both the object id: "2B6392CA-B720-4930-8E1C-14C7B06E4397" and the name "Alex Lincoln". In the example provided below, the operation searches for an object by its object id and returns it as part of the response:

data_service_get_object_by_objectId

where:

Argument                Description
table name Name of the data table from where the required object is retrieved.
object id Unique identifier of the object to retrieve.
relations Name of the related property to load. For example, if table employees has a relation column homeAddress pointing to an object in the Address table, the value of the parameter would be homeAddress. The syntax allows to add relations of relations. For example, if the same Address table has a relation country pointing to the Country table, then homeAddress.country would instruct the backend to load the related Country object.
relations depth Depth of the relations to include into the response.
properties Names of the properties/columns for which  to load the corresponding values.
exclude properties Names of the properties/columns that should not be included in the response.

The result of this operation will look as shown below after the Codeless logic runs.

data_service_example_find_object_by_id

Load All Objects From Data Table

The example below loads all objects from the employees data table.

data_service_load_objects

where:

Argument                Description
table name Name of the data table from where the objects are retrieved.
where clause A search query used by the server it to determine objects matching the condition. Refer to the Search With The Where Clause topic for more information.
having clause Sets a condition on a aggregate function to filter groups.
relations Name of the related property to load. For example, if table employees has a relation column homeAddress pointing to an object in the Address table, the value of the parameter would be homeAddress. The syntax allows to add relations of relations. For example, if the same Address table has a relation country pointing to the Country table, then homeAddress.country would instruct the backend to load the related Country object.
properties Names of the properties/columns for which  to load the corresponding values.
exclude properties Names of the properties/columns that should not be included in the response.
relations depth Depth of the relations to include into the response.
relations page size Sets the number of related objects returned in the response.
sort by Lists properties by which the returned collection should be sorted by.
group by Sets the name of the columns to group the results by.
page size Sets the page size which is the number of objects to be returned in the response.
page offset Zero-based index of the object in the persistent store from which to run the search. This parameter should be used when implementing paged access to data. Suppose the first request returned 20 objects (if pageSize is set to 20) and there are 100 objects total. The subsequent request can set offset to 20, so the next batch of objects is loaded sequentially.
distinct Used to return only unique values from a column.
file reference prefix This property allows replacing the default URL file prefix. For instance, when the operation returns a path to a file stored on the server ("https://yourdomain.backendless.app/my-file.jpg"), then you can reconstruct it by passing the new file name that must start with a slash - "/wonderful_forest.jpg". It is useful when you want the client application to open a specific file locally.

The result of this operation will look as shown below after the Codeless logic runs.

data_service_example_load_objects_2