Skip to main content

A Python client for the 1WorldSync Content1 REST API

Project description

1WorldSync Content1 API Python Client

A Python client for interacting with the 1WorldSync Content1 API.

Installation

pip install oneworldsync

Command Line Interface

The package includes a command-line tool called ows that provides quick access to common operations:

# Set up credentials (one-time setup)
mkdir -p ~/.ows
echo "ONEWORLDSYNC_APP_ID=your_app_id
ONEWORLDSYNC_SECRET_KEY=your_secret_key
ONEWORLDSYNC_USER_GLN=your_gln" > ~/.ows/credentials

# Test your credentials
ows login

# Count products
ows count
ows count --target-market US
ows count --last-days 30 --target-market US

# Fetch products
ows fetch --gtin 12345678901234
ows fetch --target-market US --output results.json
ows fetch --last-days 30 --target-market US

# Get products from the last 30 days
ows recent --target-market US

# Get product hierarchies
ows hierarchy --gtin 12345678901234

Basic Usage

from oneworldsync import Content1Client

# Initialize client with credentials
client = Content1Client(
    app_id="your_app_id",
    secret_key="your_secret_key",
    gln="your_gln"  # Optional
)

# Count products
count = client.count_products()
print(f"Total products: {count}")

# Fetch products by GTIN
products = client.fetch_products_by_gtin(["00000000000000"])

# Fetch products by target market
products = client.fetch_products_by_target_market("US")

Using the Criteria Builder

The library provides a fluent interface for building search criteria:

from oneworldsync import ProductCriteria, DateRangeCriteria, SortField

# Create criteria using the builder pattern
criteria = ProductCriteria() \
    .with_target_market("US") \
    .with_last_modified_date(DateRangeCriteria.last_30_days()) \
    .with_brand_name("Brand Name") \
    .with_sort([
        SortField.create("lastModifiedDate", descending=True)
    ])

# Use the criteria with the client
products = client.fetch_products(criteria)

# Process results
for product in products:
    print(f"{product.brand_name} - {product.gtin}")

Convenience Methods

# Get products from the last 30 days
products = client.fetch_products_last_30_days(target_market="US")

# Get products by date range
products = client.fetch_products_by_date_range(
    from_date="2023-01-01", 
    to_date="2023-01-31",
    target_market="US"
)

# Get products by brand
products = client.fetch_products_by_brand("Brand Name", target_market="US")

# Get products by GPC code
products = client.fetch_products_by_gpc_code("10000248", target_market="US")

Pagination

# Fetch first page
products = client.fetch_products(criteria, page_size=100)

# Process first page
for product in products:
    print(f"GTIN: {product.gtin}")

# Check if there are more pages
if products.search_after:
    # Fetch next page
    next_page = client.fetch_next_page(products, original_criteria=criteria)

Documentation

For more detailed documentation, see the full documentation.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

oneworldsync-0.3.3.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

oneworldsync-0.3.3-py3-none-any.whl (17.7 kB view details)

Uploaded Python 3

File details

Details for the file oneworldsync-0.3.3.tar.gz.

File metadata

  • Download URL: oneworldsync-0.3.3.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for oneworldsync-0.3.3.tar.gz
Algorithm Hash digest
SHA256 c5bf25c7a43ffd26ce89bb7ff3b77ed815d0006fb88dc60202a78195cc5d0d0a
MD5 e0269edba88f965974501f506de468d6
BLAKE2b-256 517f60c40baade15b11c8a335ec9ee7c12358dd6b49f86234694eee53bf9a0a8

See more details on using hashes here.

File details

Details for the file oneworldsync-0.3.3-py3-none-any.whl.

File metadata

  • Download URL: oneworldsync-0.3.3-py3-none-any.whl
  • Upload date:
  • Size: 17.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for oneworldsync-0.3.3-py3-none-any.whl
Algorithm Hash digest
SHA256 9bb53dd1517587ed6a289df71fcd3155e39f9df54b8dd6efd173ba2390b7c104
MD5 3fb69fb670cf521c92699e8d4a2e0e8a
BLAKE2b-256 dbe8b949459bc55131962443eb3f6eeb4326b420c2bffedbce5acd062de8ba97

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page