Searching in the bexio API

Introduction

Every resource uses the same search methods. You can search by sending a POST request to the resource (e.g.: POST /contact/search or POST /country/search). The search parameters must be provided in the body of the POST request. Please have a look at the resource documentation to see a list of available search parameters.

Criterias

You can use different criterias for the search. The criteria “like” will be used by default if you do not define a criteria.

Criteria Description
= Exact match
equal Exact match (Synonym for =)
!= Not equal
not_equal Not equal (Synonym for !=)
> Greather than
greater_than Greather than (synonym for >)
< Less than
less_than Less than (synonym for <)
>= Greater or equal then
greater_equal Greater or equal then (synonym for >=)
<= Lesser or equal then
less_equal Lesser or equal then (synonym for <=)
like Partial match
not_like Does not partial match
is_null Value is NULL
not_null Value is not NULL

Example (PHP)

Please have a look at the following example to see how the search API works. We search for a contact. The last name of the contact should be “Meyer” and the contact number should be greater than 10.

Define the search array

$data = array(
  array(
    'field' => 'name_1',
    'value' => 'Meyer',
    'criteria' => '=',
  ),
  array(
    'field' => 'nr',
    'value' => 10,
    'criteria' => '>',
  ),
);

Transform the array to JSON

json_encode($data);

POST-Body for the search

[
 {
  "field" : "name_1",
  "value" : "Meyer",
  "criteria" : "="
 },
 {
  "field" : "nr",
  "value" : 10,
  "criteria" : ">"
 }
]