Skip to content

Bulk data refactor#40

Merged
dpieski merged 6 commits intomainfrom
bulk_data_refactor
Jan 8, 2026
Merged

Bulk data refactor#40
dpieski merged 6 commits intomainfrom
bulk_data_refactor

Conversation

@dpieski
Copy link
Copy Markdown
Contributor

@dpieski dpieski commented Jan 8, 2026

Refactor BulkDataClient for USPTO API Alignment

Summary

Refactor BulkDataClient to align with actual USPTO Bulk Data API behavior and improve download functionality.

  • Remove deprecated get_products() method (use search_products() instead)
  • Fix file download endpoint to use proper URL structure ({productIdentifier}/{fileName})
  • Add validation warning when API returns unexpected product ID
  • Expand bulk data models with additional fields from API responses
  • Update examples to demonstrate actual working API methods
  • Improve test coverage for bulk data operations

Changes

Client (src/pyUSPTO/clients/bulk_data.py)

  • Breaking: Removed get_products() method - callers should use search_products()
  • Fixed download_file() endpoint construction to match API spec
  • Added product ID validation in get_product_by_id() with warning for mismatches
  • Improved docstrings with examples

Models (src/pyUSPTO/models/bulk_data.py)

  • Added missing fields to BulkDataProduct model from API responses
  • Expanded FileData model with additional metadata fields
  • Improved type safety and field documentation

Examples (examples/bulk_data_example.py)

  • Complete rewrite using only supported API methods
  • Demonstrates search, pagination, product retrieval, and file downloads
  • Added example for finding smallest file for testing
  • Shows both extraction and non-extraction download modes
  • Removed examples using non-existent API features

Tests

  • Updated unit tests to reflect new client behavior
  • Enhanced integration tests with real API scenarios
  • Added model tests for new fields

Notes

The USPTO Bulk Data API only supports full-text search via the query parameter. Field-specific queries and date/label filtering are not supported despite being documented in the API swagger specification.

@dpieski dpieski merged commit 7f8d117 into main Jan 8, 2026
7 checks passed
@dpieski dpieski deleted the bulk_data_refactor branch January 11, 2026 21:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant