Client API

The client module provides the main interface for interacting with the 1WorldSync API.

OneWorldSyncClient

class oneworldsync.client.OneWorldSyncClient(app_id=None, secret_key=None, api_url=None, timeout=30)[source]

Bases: object

Client for the 1WorldSync API

This class provides methods for interacting with the 1WorldSync API, handling authentication, request construction, and response parsing.

__init__(app_id=None, secret_key=None, api_url=None, timeout=30)[source]

Initialize the 1WorldSync API client

Parameters:
  • app_id (str, optional) – The application ID provided by 1WorldSync. If None, will try to get from ONEWORLDSYNC_APP_ID environment variable.

  • secret_key (str, optional) – The secret key provided by 1WorldSync. If None, will try to get from ONEWORLDSYNC_SECRET_KEY environment variable.

  • api_url (str, optional) – The API URL to use. If None, will try to get from ONEWORLDSYNC_API_URL environment variable. Defaults to preprod API if not specified.

  • timeout (int, optional) – Request timeout in seconds. Defaults to 30.

search_products(query, search_type='freeTextSearch', access_mdm='computer', geo_location=None, **kwargs)[source]

Search for products using the 1WorldSync API

Parameters:
  • query (str) – Search query

  • search_type (str, optional) – Type of search (‘freeTextSearch’, ‘advancedSearch’, ‘categoryCode’). Defaults to ‘freeTextSearch’.

  • access_mdm (str, optional) – Access MDM. Defaults to ‘computer’.

  • geo_location (tuple, optional) – Tuple of (latitude, longitude). Defaults to None.

  • **kwargs – Additional search parameters

Returns:

Search results

Return type:

dict

get_product(product_id, access_mdm='computer', geo_location=None, **kwargs)[source]

Get a product by ID from the search results. It is not a UPC/EAN/GTIN. itemReferenceId is the 1WorldSync assigned unique identifier for this product.

Parameters:
  • product_id (str) – Product ID

  • access_mdm (str, optional) – Access MDM. Defaults to ‘computer’.

  • geo_location (tuple, optional) – Tuple of (latitude, longitude). Defaults to None.

  • **kwargs – Additional parameters

Returns:

Product details

Return type:

dict

Perform an advanced search

Parameters:
  • field (str) – Field to search in

  • value (str) – Value to search for

  • access_mdm (str, optional) – Access MDM. Defaults to ‘computer’.

  • **kwargs – Additional search parameters

Returns:

Search results

Return type:

dict

Perform a free text search

Parameters:
  • query (str) – Search query

  • access_mdm (str, optional) – Access MDM. Defaults to ‘computer’.

  • **kwargs – Additional search parameters

Returns:

Search results

Return type:

dict