Using Search Functionality

This guide provides an overview of how to utilize the search functionality in Wodify APIs effectively. By following the guidelines outlined here, you can construct precise queries to retrieve the desired data from any search-enabled API endpoint.

🚀 Overview

The search functionality in Wodify APIs allows you to perform complex queries to filter data based on specific criteria. By leveraging various operators and clause syntax, you can tailor your searches to retrieve precisely the data you need.

🔣 Syntax

The search functionality uses a combination of operators and clause syntax to construct queries. Below is an overview of the key components:

  • Field: The data field to search on.
  • Operator: Defines the type of comparison to be made (e.g., less than, equal to, within a range) between the field and the provided value.
  • Value: The value or values to search for.
  • Separator: The character that must be used in between each search query component. Wodify APIs use the pipe symbol, or |, as a separator.
  • Accepted Types: The data types that the provided value can have given the in-use operator.

A query prior to URL encoding should adhere to the following structure:

field|operator|value

Available Operators

Basic Comparison Operators

Basic comparison operators are used for comparing values directly against each other, such as comparing numbers, dates, text, or boolean values.

OperatorDescriptionAccepted Types
ltLess thanDate, number
lteLess than or equal toDate, number
gtGreater thanDate, number
gteGreater than or equal toDate, number
eqEqual toDate, text, number, boolean
neqNot equal toDate, text, number, boolean

Specialized Operators

Specialized operators provide additional functionality for performing specific types of searches or comparisons that go beyond simple value comparisons. They often involve more complex conditions or multiple values, and are useful for scenarios where you need to search within a range (between), check for membership in a list (in, not_in), verify the presence or absence of a value (not_null, is_null), or perform text-based searches (like, starts_with, ends_with, not_like).

OperatorDescriptionAccepted Types
betweenWithin the specified rangeNumber
inIncluded within the specified listText, number
not_inNot included within the specified listText, number
not_nullHas a value for the specified propertyDate, text, number
is_nullDoesn't have a value for the specified propertyDate, text
containsText contains a valueText
starts_withText starts with a valueText
ends_withText ends with a valueText
not_likeText doesn't contain a tokenText

Unencoded Clause Syntax Examples

The following examples show how one might construct a search query for each of the operators listed above.

  • Age less than 40: age|lt|40;
  • Age less than or equal to 40: age|lte|40;
  • Age greater than 40: age|gt|40;
  • Age greater than or equal to 40: age|gte|40;
  • Age equal to 40: age|eq|40;
  • Age not equal to 40: age|neq|40
  • Height between 60 and 70: height|between|60|70;
  • Height is in 60, 61, 62: height|in|{60,61,62};
  • Height is not in 60, 61, 61: height|not_in|{60,61,62};
  • Email has a value: email|not_null
  • Email does not have a value: email|is_null
  • Name contains 'c': name|contains|'c'
  • Name starts with 'c': name|starts_with|'c'
  • Name ends with 'c': name|ends_with|'c'
  • Name does not contain 'c': name|not_like|'c'

Guidelines for Constructing Queries

  • Use a semicolon, ; , to separate multiple search values for 'q'. Multiple searches provided for 'q' are treated as "AND" conditions.
  • Use the standard separator, | , between your minimum and maximum values for queries using the between operator.
  • Use curly braces, { } , around a comma-separated list of values for queries using the in or not_in operator.
  • Use single quotes, ' ' , around text values.

URL Encoding Queries

In the context of Wodify's APIs, the query string parameter 'q' must be URL encoded when constructing API requests. URL encoding ensures that special characters within the query string are properly formatted and transmitted in a URL-safe manner.

URL encoding involves replacing certain characters with a percent sign (%) followed by their ASCII hexadecimal representation. This encoding mechanism allows special characters, such as spaces or symbols, to be included in the query string without causing parsing errors or misinterpretations by the server.

To URL encode the 'q' parameter, you can use built-in functions or libraries provided by your programming language or framework. By adhering to URL encoding standards, you can ensure the integrity and accuracy of your API requests.

🔍 Example Queries

Search for Clients with On-ramp status and sort by their email address

  1. Build the unencoded query.

    • The field is client_status.
    • The operator is eq.
    • The value is 'On-ramp'.
    Unencoded query => client_status|eq|'On-ramp'
  2. URL encode the query.

    URL encoded query => client_status%7Ceq%7C%27On-ramp%27
  3. Build the request URL.

    Request URL => https://api.wodify.com/v1/clients/search?q="client_status%7Ceq%7C%27On-ramp%27"&sort=email

What’s Next