Configuration — pyUSPTO 0.2.3.dev1+g2c5d89b38.d20251125 documentation

# Configuration

config - Configuration management for USPTO API clients

This module provides configuration management for USPTO API clients, including API keys, base URLs, and HTTP transport settings.

class pyUSPTO.config.USPTOConfig(api_key=None, bulk_data_base_url='https://api.uspto.gov', patent_data_base_url='https://api.uspto.gov', petition_decisions_base_url='https://api.uspto.gov', ptab_base_url='https://api.uspto.gov', http_config=None, include_raw_data=False)

  Bases: `object`

  Configuration for USPTO API clients.

  Manages API-level configuration (keys, URLs) and optionally accepts HTTP transport configuration via HTTPConfig.

  __init__(api_key=None, bulk_data_base_url='https://api.uspto.gov', patent_data_base_url='https://api.uspto.gov', petition_decisions_base_url='https://api.uspto.gov', ptab_base_url='https://api.uspto.gov', http_config=None, include_raw_data=False)

    Initialize the USPTOConfig.

    Parameters:

      - api_key (`str` | `None`) – API key for authentication, defaults to USPTO_API_KEY environment variable

      - bulk_data_base_url (`str`) – Base URL for the Bulk Data API

      - patent_data_base_url (`str`) – Base URL for the Patent Data API

      - petition_decisions_base_url (`str`) – Base URL for the Final Petition Decisions API

      - ptab_base_url (`str`) – Base URL for the PTAB (Patent Trial and Appeal Board) API

      - http_config (`HTTPConfig` | `None`) – Optional HTTPConfig for request handling (uses defaults if None)

      - include_raw_data (`bool`) – If True, store raw JSON in response objects for debugging (default: False)

  classmethod from_env()

    Create a USPTOConfig from environment variables.

    Return type:

      `USPTOConfig`

    Returns:

      USPTOConfig instance with values from environment

http_config - HTTP client configuration for USPTO API requests

This module provides configuration for HTTP transport-level settings including timeouts, retries, connection pooling, and custom headers.

class pyUSPTO.http_config.HTTPConfig(timeout=30.0, connect_timeout=10.0, max_retries=3, backoff_factor=1.0, retry_status_codes=<factory>, pool_connections=10, pool_maxsize=10, custom_headers=None)

  Bases: `object`

  HTTP client configuration for request handling.

  This class separates transport-level HTTP concerns from API-level configuration, allowing fine-grained control over request behavior.

  timeout

    Read timeout in seconds for requests (default: 30.0)

  connect_timeout

    Connection establishment timeout in seconds (default: 10.0)

  max_retries

    Maximum number of retry attempts (default: 3)

  backoff_factor

    Exponential backoff multiplier for retries (default: 1.0)

  retry_status_codes

    HTTP status codes that trigger retries

  pool_connections

    Number of connection pools to cache (default: 10)

  pool_maxsize

    Maximum number of connections per pool (default: 10)

  custom_headers

    Additional headers to include in all requests

  backoff_factor: `float` = 1.0
  connect_timeout: `float` | `None` = 10.0
  custom_headers: `Dict`[`str`, `str`] | `None` = None
  classmethod from_env()

    Create HTTPConfig from environment variables.

    Environment variables:

      USPTO_REQUEST_TIMEOUT: Request timeout in seconds USPTO_CONNECT_TIMEOUT: Connection timeout in seconds USPTO_MAX_RETRIES: Maximum retry attempts USPTO_BACKOFF_FACTOR: Retry backoff factor USPTO_POOL_CONNECTIONS: Connection pool size USPTO_POOL_MAXSIZE: Max connections per pool

    Return type:

      `HTTPConfig`

    Returns:

      HTTPConfig instance with values from environment or defaults

  get_timeout_tuple()

    Get timeout as tuple for requests library.

    Return type:

      `tuple`[`float` | `None`, `float` | `None`]

    Returns:

      Tuple of (connect_timeout, read_timeout) for requests

  max_retries: `int` = 3
  pool_connections: `int` = 10
  pool_maxsize: `int` = 10
  retry_status_codes: `List`[`int`]
  timeout: `float` | `None` = 30.0