Filtering requests API

Tags: Flow

The Flow API is built using the Django Rest Framework and supports basic and enhanced filtering options. Most operators are supported. Learn more about Django REST framework (opens in new tab).

Who can use this?

 Core
Plus
 
   


Basic filter options

Flow filters using standard Rest syntax using the object ID.

For example, to obtain a specific user record, you would submit the following request:

https://flow.pluralsight.com/v3/customer/core/users/?id=1234567890

Where:

1234567890 is the specific User Id being requested.

Field Inclusion and Omission

The API provides a mechanism to limit the fields returned for a given object using the Fields and Omit keywords. This can help with performance and limit the scope of data sent to the client application.

Fields Keyword

To limit the response to a specific set of fields, use the Fields keyword and provide a comma-separated list of field names.

Here’s an example:

https://flow.pluralsight.com/v3/customer/core/users/?fields=id,name,email&limit=3

This will return three user records with only the id, name, and email fields.

Omit Keyword

To limit the fields to a select few, use the Omit keyword and provide a comma-separated list of field names.

Here’s an example:

https://flow.pluralsight.com/v3/customer/core/users/?omit=email,teams

This will return all fields in the Users object with the email and teams fields omitted:

back to top


Enhanced filter options

The Flow API offers basic and enhanced filtering options for filtering objects. These filter options greatly improve performance by returning exactly the objects you want.

There are several built-in filter options for searching:

gt

Filters for records that are greater than the specified value.

Example: All Commits whose lines of new_work code is greater than 100000.

Request

https://flow.pluralsight.com/v3/customer/core/commits/?new_work__gt=100000

Response:

gte

Filters for records that are greater than or equal to the specified value.

Example: All Commits whose lines of new work code greater than or equal to 2695.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?new_work__gte=2695

Response:

lt

Filters for records that are less than the specified value.

Example: All Commits whose lines of new work code less than 10.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?new_work__lt=10

Response:

lte

Filters for records that are less than or equal to the specified value.

Example: All Commits whose lines of new work code is less than or equal to one.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?new_work__lte=1

Response:

in

Filters for records that are in a list of specified values.

Example: Repository ID is in 168294.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?repo_id__in=168294

Response:

icontains

A case-insensitive string containment test equivalent to ILIKE “%foo%’ in SQL.

Example: Commit message that contains the word progress.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?message__icontains=progress

Response:

startswith

A case-sensitive search for records that start with the specified string.

Example: User name contains george.

Request:

https://flow.pluralsight.com/v3/customer/core/users/?name__startswith=george

Response:

between

Filters for records that fall within the specified range of values. Flow does not currently have a between filter. You use __gte and __lt filters to create a between.

Example: Commits created between June 8, 2018 and June 15, 2018.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?author_date__gte=2018-06-08&author_date__lt=2018-06-15

Response:

equals

A case-sensitive exact string match.

Example:Repository vendor type is github.

Request:

https://flow.pluralsight.com/v3/customer/core/repos/?vendor_type=github

Response:

not equal to

A case-sensitive match for all records that are not an exact string match.

Example: Repository vendor type is not github.

Request:

https://flow.pluralsight.com/v3/customer/core/repos/?vendor_type!=github

Response:

remove_excluded

Filters for Commits that are not flagged as being excluded.

Example:All Commits except those with excluded Users.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?remove_excluded=true

Response:

smart_dedupe

Excludes duplicate Commits.

The Flow de-duplication ensures each unique commit is represented once and only once. Certain branching and merging activities can cause git to create multiple HexSHA’s for the same work. This makes sure you don’t double count.

Example:All Commits; no duplicate records.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?smart_dedupe=true

exclude_weekends

Filters for Commits committed on weekdays.

Example:All Commits except those created on a Saturday or Sunday.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?exclude_weekends=true

Response:

exclude_outliers

Filters for Commits that have been marked as outliers. Learn more about outliers.

Example:All Commits that have been excluded due to outlier detection.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?exclude_outliers=true

Response:

exclude_blocked

Filters for Commits that are not associated with blocked or unprocessed repos.

Example: Commits with no blocked repos.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?exclude_blocked=true

Response:

normalize_authors

Replaces all User IDs with their respective main alias record.

Example:All Commits; User alias ID matching main, apex user ID.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?normalize_authors=true

Response:

apply_default_filters

Applies the default set of filters: smart_dedupe, exclude_outliers, exclude_pr_orphans, exclude_merge, and exclude_blocked.

This will give you the best match to Flow's reports.

Example:All Commits except those matching the default filters.

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?apply_default_filters=true

Response:

back to top


Customizing results

Filtering your requests helps to restrict the data that is reported, but the results you Get can still be too sizeable to manage. Customizing your results helps to keep the data concise.

Ordering

Use ordering to alter the sort order and type of the results. Place a - in front of the parameter you are ordering by to get results in descending order.

Example: &ordering=-id

Request:

https://flow.pluralsight.com/v3/customer/core/commits/?fields=id,new_work,churn&limit=5&ordering=id

Response:

id="pagination">Pagination

Flow uses limit and offset pagination options:

  • limit – restricts the results to a specific number of data rows. For example, setting limit to 5 means that the system only returns the first five rows in the matching record set.
  • offset – indicates where to start the results. A common practice is to combine this option with limit. For example, you could limit the request to only 50 records and specify an offset of 10, which would result in results of records 11 to 50.

Note: The maximum page size is 1,000. This is set by the limit parameter.

Here is an example:

Request:

https://flow.pluralsight.com/v3/customer/core/users/?fields=id,name&ordering=name&limit=5

Response:

The request with multiple options returns nice and clean results, but there are three important things about the response that should catch your attention:

  • Although there is a count of 22598 records, the response shows only five records, as we requested.
  • Instead of returning all user fields, the system has returned the two we wanted: id and name.
  • The records are in alpha order since we specified order by name.

back to top


If you need help, please contact Pluralsight Support.