USPTOConfig
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', enriched_citations_base_url='https://api.uspto.gov', http_config=None, include_raw_data=False)[source]
Bases:
objectConfiguration for USPTO API clients.
Manages API-level configuration (keys, URLs) and optionally accepts HTTP transport configuration via HTTPConfig.
- __exit__(exc_type, exc_val, exc_tb)[source]
Exit context manager, closing the session.
- Return type:
- __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', enriched_citations_base_url='https://api.uspto.gov', http_config=None, include_raw_data=False)[source]
Initialize the USPTOConfig.
- Parameters:
api_key (
str|None) – API key for authentication, defaults to USPTO_API_KEY environment variablebulk_data_base_url (
str) – Base URL for the Bulk Data APIpatent_data_base_url (
str) – Base URL for the Patent Data APIpetition_decisions_base_url (
str) – Base URL for the Final Petition Decisions APIptab_base_url (
str) – Base URL for the PTAB (Patent Trial and Appeal Board) APIenriched_citations_base_url (
str) – Base URL for the Enriched Citations APIhttp_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)
- close()[source]
Close the HTTP session and release resources.
This should be called when you’re done using this config and all clients created from it. After calling close(), the session will be recreated if accessed again.
Example
config = USPTOConfig(api_key=”…”) client = PatentDataClient(config=config) try:
# Use client pass
- finally:
config.close()
- Return type:
- classmethod from_env()[source]
Create a USPTOConfig from environment variables.
- Return type:
- Returns:
USPTOConfig instance with values from environment
- property session: Session
Get the HTTP session for this config, creating it if needed.
The session is created lazily on first access and reused for all subsequent requests. All clients sharing this config will use the same session for connection pooling.
- Returns:
The requests Session object with configured adapters.
- Return type:
Session