Criteria API

The criteria module provides classes for building search criteria for the 1WorldSync Content1 API.

DateRangeCriteria

class oneworldsync.criteria.DateRangeCriteria[source]

Bases: object

Builder for date range criteria

static between(from_date, to_date)[source]

Create a date range criteria between two dates

Parameters:
  • from_date (str) – Start date in YYYY-MM-DD format

  • to_date (str) – End date in YYYY-MM-DD format

Returns:

Date range criteria

Return type:

dict

static last_days(days)[source]

Create a date range criteria for the last N days

Parameters:

days (int) – Number of days to look back

Returns:

Date range criteria

Return type:

dict

static last_30_days()[source]

Create a date range criteria for the last 30 days

Returns:

Date range criteria

Return type:

dict

SortField

class oneworldsync.criteria.SortField[source]

Bases: object

Builder for sort field criteria

static create(field, descending=False)[source]

Create a sort field criteria

Parameters:
  • field (str) – Field name to sort by

  • descending (bool, optional) – Sort in descending order. Defaults to False.

Returns:

Sort field criteria

Return type:

dict

ProductCriteria

class oneworldsync.criteria.ProductCriteria[source]

Bases: object

Builder for product search criteria

__init__()[source]

Initialize an empty product criteria

with_gtin(gtins)[source]

Add GTIN criteria

Parameters:

gtins (List[str]) – List of GTINs to search for

Returns:

Self for chaining

Return type:

ProductCriteria

with_ip_gln(ip_gln)[source]

Add Information Provider GLN criteria

Parameters:

ip_gln (str) – Information Provider GLN

Returns:

Self for chaining

Return type:

ProductCriteria

with_target_market(target_market)[source]

Add target market criteria

Parameters:

target_market (str) – Target market code (e.g., ‘US’)

Returns:

Self for chaining

Return type:

ProductCriteria

with_last_modified_date(date_range)[source]

Add last modified date criteria

Parameters:

date_range (Dict) – Date range criteria created with DateRangeCriteria

Returns:

Self for chaining

Return type:

ProductCriteria

with_brand_name(brand_name)[source]

Add brand name criteria

Parameters:

brand_name (str) – Brand name to search for

Returns:

Self for chaining

Return type:

ProductCriteria

with_product_type(product_type)[source]

Add product type criteria

Parameters:

product_type (str) – Product type (e.g., ‘EA’)

Returns:

Self for chaining

Return type:

ProductCriteria

with_consumer_unit(is_consumer_unit)[source]

Add consumer unit criteria

Parameters:

is_consumer_unit (bool) – Whether the product is a consumer unit

Returns:

Self for chaining

Return type:

ProductCriteria

with_gpc_code(gpc_code)[source]

Add GPC code criteria

Parameters:

gpc_code (str) – GPC code to search for

Returns:

Self for chaining

Return type:

ProductCriteria

with_upc_code(upc_code)[source]

Add UPC code criteria

Parameters:

upc_code (str) – UPC code to search for

Returns:

Self for chaining

Return type:

ProductCriteria

with_sort(sort_fields)[source]

Add sort criteria

Parameters:

sort_fields (List[Dict]) – List of sort fields created with SortField

Returns:

Self for chaining

Return type:

ProductCriteria

with_fields(include=None, exclude=None)[source]

Add field inclusion/exclusion criteria

Parameters:
  • include (List[str], optional) – Fields to include. Defaults to None.

  • exclude (List[str], optional) – Fields to exclude. Defaults to None.

Returns:

Self for chaining

Return type:

ProductCriteria

with_search_after(search_after)[source]

Add search after criteria for pagination

Parameters:

search_after (List) – Search after token from previous response

Returns:

Self for chaining

Return type:

ProductCriteria

with_hierarchy(pull_hierarchy=True)[source]

Add hierarchy criteria

Parameters:

pull_hierarchy (bool, optional) – Whether to pull hierarchy. Defaults to True.

Returns:

Self for chaining

Return type:

ProductCriteria

build()[source]

Build the criteria dictionary

Returns:

Complete criteria dictionary

Return type:

dict