Generic Search

Search a string across several text fields at once with the search parameter.

Sometimes you want to find an entity by a string without knowing which field it lives in. Because URL query parameters can't express an OR across fields, the Platform API provides a single search parameter that matches against several text fields at once:

  • label
  • name
  • description
  • username
  • firstName
  • lastName

Add search=<string> to any list endpoint:

# Find any device or variable referencing "vaccine"
curl -X GET 'https://api.surfact.com/api/v2.0/devices/?search=vaccine' \
  -H 'X-Auth-Token: your_token_here'
{
  "count": 1,
  "next": null,
  "previous": null,
  "results": [
    {
      "label": "vaccine-box-09",
      "name": "Vaccine Box 09",
      "description": "Insulated pharma shipper"
    }
  ]
}

Refining the match

search can be combined with a match modifier for finer control:

ModifierBehaviour
iexactCase-insensitive exact match
contains / icontainsSubstring match (case-insensitive variant)
startswith / istartswithPrefix match
endswith / iendswithSuffix match
# Devices whose searchable fields start with "reefer"
curl -X GET 'https://api.surfact.com/api/v2.0/devices/?search__istartswith=reefer' \
  -H 'X-Auth-Token: your_token_here'
👍

Search vs. filter

Use Generic Search when you want one term matched across many fields (great for a UI search box). Use Field Filters when you need to target a specific attribute precisely.


Did this page help you?