Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 18 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,13 @@
[![Python 3.10+](https://img.shields.io/badge/python-3.10+-blue.svg)](https://www.python.org/downloads/)
[![Read the Docs](https://img.shields.io/readthedocs/pyuspto)](https://pyuspto.readthedocs.io/en/latest/)

A Python client library for interacting with the USPTO APIs.
A Python client library for interacting with the United Stated Patent and Trademark Office (USPTO) [Open Data Portal](https://data.uspto.gov/home) APIs.

This package provides clients for interacting with both the USPTO Bulk Data API and the USPTO Patent Data API.
The client for the Final Petition Decisions API is currently being developed.

> [!IMPORTANT]
> The USPTO is in the process of moving their API. This package is only concerned with the new API. The [old API](https://developer.uspto.gov/) will be retired at the end of 2025.

## Quick Start

Expand All @@ -29,17 +33,20 @@ pip install -e .

### Configuration Options

> [!IMPORTANT]
> You must have an API key for the [USPTO Open Data Portal API](https://data.uspto.gov/myodp/landing).

There are multiple ways to configure the USPTO API clients:


```python
from pyUSPTO import PatentDataClient
from pyUSPTO.config import USPTOConfig
import os

# Method 1: Direct API key initialization
client1 = PatentDataClient(api_key="your_api_key_here")

# Method 2: Using USPTOConfig with explicit parameters
from pyUSPTO.config import USPTOConfig
config = USPTOConfig(
api_key="your_api_key_here",
bulk_data_base_url="https://api.uspto.gov/api/v1/datasets",
Expand All @@ -48,6 +55,7 @@ config = USPTOConfig(
client2 = PatentDataClient(config=config)

# Method 3: Using environment variables (recommended for production)
import os
os.environ["USPTO_API_KEY"] = "your_api_key_here"
config_from_env = USPTOConfig.from_env()
client3 = PatentDataClient(config=config_from_env)
Expand All @@ -68,18 +76,22 @@ print(f"Found {inventor_search.count} applications with 'Smith' as inventor")
- Search for patent applications using various filters
- Download files and documents from the APIs

## Data Models
## Documentation

Full documentation may be found on [Read the Docs](https://pyuspto.readthedocs.io/).

### Data Models

The library uses Python dataclasses to represent API responses. All data models include type annotations for attributes and methods, making them fully compatible with static type checkers.

### Bulk Data API
#### Bulk Data API

- `BulkDataResponse`: Top-level response from the API
- `BulkDataProduct`: Information about a specific product
- `ProductFileBag`: Container for file data elements
- `FileData`: Information about an individual file

### Patent Data API
#### Patent Data API

- `PatentDataResponse`: Top-level response from the API
- `PatentFileWrapper`: Information about a patent application
Expand Down
4 changes: 2 additions & 2 deletions src/pyUSPTO/models/patent_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def serialize_bool_to_yn(value: Optional[bool]) -> Optional[str]:
Optional[str]: "Y" if `value` is True, "N" if `value` is False.
Returns None if `value` is None.
"""

if value is None:
return None
return "Y" if value else "N"
Expand Down Expand Up @@ -544,7 +544,7 @@ def to_dict(self) -> Dict[str, Any]:
Returns:
Dict[str, Any]: A dictionary representation of the address.
"""

return {
"nameLineOneText": self.name_line_one_text,
"nameLineTwoText": self.name_line_two_text,
Expand Down