-
Notifications
You must be signed in to change notification settings - Fork 3
Add Enriched Citations API Endpoint #130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
4fedf9f
feat: init enriched citations
dpieski 59fcdbf
fix: improve tests, add form_urlencoded to requests for citations
dpieski 92de568
fix: paginate results for solr endpoints
dpieski c808946
docs: update docs with new endpoint.
dpieski b245a59
chore: add examples
dpieski File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Enriched Citations Client | ||
| ========================= | ||
|
|
||
| .. automodule:: pyUSPTO.clients.enriched_citations | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ Clients | |
| :maxdepth: 2 | ||
|
|
||
| bulk_data | ||
| enriched_citations | ||
| patent_data | ||
| petition_decisions | ||
| ptab_appeals | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| Enriched Citations | ||
| ================== | ||
|
|
||
| .. automodule:: pyUSPTO.models.enriched_citations | ||
| :members: | ||
| :undoc-members: | ||
| :show-inheritance: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,6 +6,7 @@ Models | |
|
|
||
| base | ||
| bulk_data | ||
| enriched_citations | ||
| patent_data | ||
| petition_decisions | ||
| ptab | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| Enriched Citations Example | ||
| ========================== | ||
|
|
||
| .. literalinclude:: ../../../examples/enriched_citations_example.py | ||
| :language: python | ||
| :linenos: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,6 +5,7 @@ Examples | |
| :maxdepth: 2 | ||
|
|
||
| bulk_data | ||
| enriched_citations | ||
| patent_data | ||
| ifw_example | ||
| petition_decisions | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,132 @@ | ||
| """Example usage of pyUSPTO for Enriched Cited Reference Metadata. | ||
|
|
||
| Demonstrates the EnrichedCitationsClient for searching citation data | ||
| extracted from patent office actions, filtering by various criteria, | ||
| and paginating through results. | ||
| """ | ||
|
|
||
| import os | ||
|
|
||
| from pyUSPTO import EnrichedCitationsClient, USPTOConfig | ||
|
|
||
| # --- Client Initialization --- | ||
| api_key = os.environ.get("USPTO_API_KEY", "YOUR_API_KEY_HERE") | ||
| if api_key == "YOUR_API_KEY_HERE": | ||
| raise ValueError( | ||
| "API key is not set. Set the USPTO_API_KEY environment variable." | ||
| ) | ||
| config = USPTOConfig(api_key=api_key) | ||
| client = EnrichedCitationsClient(config=config) | ||
|
|
||
| print("-" * 40) | ||
| print("Example 1: Search by application number") | ||
| print("-" * 40) | ||
|
|
||
| response = client.search_citations(patent_application_number_q="15061308") | ||
| print(f"Found {response.num_found} citations for application 15061308.") | ||
| for citation in response.docs[:5]: | ||
| print(f"\n Cited Document: {citation.cited_document_identifier}") | ||
| print(f" Category Code: {citation.citation_category_code}") | ||
| print(f" Office Action Date: {citation.office_action_date}") | ||
| print(f" Office Action Type: {citation.office_action_category}") | ||
| if citation.examiner_cited_reference_indicator: | ||
| print(" Cited by: Examiner") | ||
| if citation.passage_location_text: | ||
| print(f" Passages: {citation.passage_location_text}") | ||
|
|
||
| print("-" * 40) | ||
| print("Example 2: Search by tech center and citation category") | ||
| print("-" * 40) | ||
|
|
||
| response = client.search_citations( | ||
| tech_center_q="2800", | ||
| citation_category_code_q="X", | ||
| rows=5, | ||
| ) | ||
| print(f"Found {response.num_found} 'X' citations in tech center 2800.") | ||
| for citation in response.docs: | ||
| print( | ||
| f" App {citation.patent_application_number}: " | ||
| f"{citation.cited_document_identifier} " | ||
| f"(claims: {citation.related_claim_number_text})" | ||
| ) | ||
|
|
||
| print("-" * 40) | ||
| print("Example 3: Search by date range") | ||
| print("-" * 40) | ||
|
|
||
| response = client.search_citations( | ||
| office_action_date_from_q="2019-01-01", | ||
| office_action_date_to_q="2019-12-31", | ||
| rows=5, | ||
| ) | ||
| print(f"Found {response.num_found} citations from 2019.") | ||
|
|
||
| print("-" * 40) | ||
| print("Example 4: Combined filters") | ||
| print("-" * 40) | ||
|
|
||
| response = client.search_citations( | ||
| tech_center_q="2800", | ||
| citation_category_code_q="Y", | ||
| examiner_cited_q=True, | ||
| rows=5, | ||
| ) | ||
| print( | ||
| f"Found {response.num_found} examiner-cited 'Y' citations in tech center 2800." | ||
| ) | ||
| for citation in response.docs: | ||
| print( | ||
| f" App {citation.patent_application_number}: " | ||
| f"{citation.cited_document_identifier} " | ||
| f"(art unit: {citation.group_art_unit_number})" | ||
| ) | ||
|
|
||
| print("-" * 40) | ||
| print("Example 5: Search with sort") | ||
| print("-" * 40) | ||
|
|
||
| response = client.search_citations( | ||
| tech_center_q="2800", | ||
| sort="officeActionDate desc", | ||
| rows=5, | ||
| ) | ||
| print(f"Found {response.num_found} citations, sorted by date descending.") | ||
| for citation in response.docs: | ||
| print(f" {citation.office_action_date}: {citation.cited_document_identifier}") | ||
|
|
||
| print("-" * 40) | ||
| print("Example 6: Search by cited document identifier") | ||
| print("-" * 40) | ||
|
|
||
| response = client.search_citations( | ||
| cited_document_identifier_q="US 20190165601 A1", | ||
| rows=5, | ||
| ) | ||
| print(f"Found {response.num_found} citations of US 20190165601 A1.") | ||
|
|
||
| print("-" * 40) | ||
| print("Example 7: Paginate through results") | ||
| print("-" * 40) | ||
|
|
||
| max_items = 30 | ||
| count = 0 | ||
| for citation in client.paginate_citations( | ||
dpieski marked this conversation as resolved.
Dismissed
Show dismissed
Hide dismissed
|
||
| tech_center_q="2800", rows=10 | ||
| ): | ||
| count += 1 | ||
| if count >= max_items: | ||
| print(f" ... (stopping at {max_items} items)") | ||
| break | ||
|
|
||
| print(f"Retrieved {count} citations via pagination") | ||
|
|
||
| print("-" * 40) | ||
| print("Example 8: Get available fields") | ||
| print("-" * 40) | ||
|
|
||
| fields_response = client.get_fields() | ||
| print(f"API Status: {fields_response.api_status}") | ||
| print(f"Field Count: {fields_response.field_count}") | ||
| print(f"Fields: {fields_response.fields}") | ||
| print(f"Last Updated: {fields_response.last_data_updated_date}") | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Check notice
Code scanning / CodeQL
Unused global variable Note
Copilot Autofix
AI 3 days ago
In general, when a loop or global variable is intentionally unused, it should be given a conventional “unused” name (such as
_or a name containingunused) so that both humans and static analysis tools recognize it as deliberate. Otherwise, the unused variable should be removed.Here, the loop on lines 114–116 iterates over
client.paginate_citations(...)but never usescitation. The best fix without changing functionality is to rename the loop variable fromcitationto_, which signals it is intentionally unused while leaving the logic (incrementingcount, enforcingmax_items, and breaking) unchanged. No imports or additional definitions are needed, and no other parts of the file reference this particular loop variable, so the change is localized to theforstatement inexamples/enriched_citations_example.py.