-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoa_citations_example.py
More file actions
106 lines (87 loc) · 3.15 KB
/
oa_citations_example.py
File metadata and controls
106 lines (87 loc) · 3.15 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
"""Example usage of pyUSPTO for Office Action Citations.
Demonstrates the OACitationsClient for searching citation data from
Office Actions, filtering by various criteria, and paginating through results.
"""
import os
from pyUSPTO import OACitationsClient, 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 = OACitationsClient(config=config)
print("-" * 40)
print("Example 1: Search by application number")
print("-" * 40)
response = client.search(patent_application_number_q="17519936")
print(f"Found {response.num_found} citations for application 17519936.")
for record in response.docs[:3]:
print(f"\n Legal Section: {record.legal_section_code}")
print(f" Action Type: {record.action_type_category}")
print(f" Reference: {record.reference_identifier}")
print(f" Examiner Cited: {record.examiner_cited_reference_indicator}")
print("-" * 40)
print("Example 2: Search by legal section code and tech center")
print("-" * 40)
response = client.search(
tech_center_q="2800",
legal_section_code_q="103",
rows=5,
)
print(f"Found {response.num_found} section 103 citations in tech center 2800.")
for record in response.docs:
print(
f" App {record.patent_application_number}: "
f"AU {record.group_art_unit_number}, "
f"ref {record.parsed_reference_identifier}"
)
print("-" * 40)
print("Example 3: Search by examiner-cited indicator")
print("-" * 40)
response = client.search(
examiner_cited_reference_indicator_q=True,
tech_center_q="1700",
rows=5,
)
print(f"Found {response.num_found} examiner-cited references in tech center 1700.")
for record in response.docs:
print(f" {record.reference_identifier}")
print("-" * 40)
print("Example 4: Search by create date range")
print("-" * 40)
response = client.search(
create_date_time_from_q="2025-07-01",
create_date_time_to_q="2025-07-04",
rows=5,
)
print(f"Found {response.num_found} citations created 2025-07-01 to 2025-07-04.")
print("-" * 40)
print("Example 5: Search with sort")
print("-" * 40)
response = client.search(
tech_center_q="2800",
sort="createDateTime desc",
rows=5,
)
print(f"Found {response.num_found} citations in tech center 2800 (newest first).")
for record in response.docs:
print(f" {record.create_date_time}: {record.patent_application_number}")
print("-" * 40)
print("Example 6: Paginate through results")
print("-" * 40)
max_items = 30
count = 0
for _ in client.paginate(tech_center_q="2800", rows=10):
count += 1
if count >= max_items:
print(f" ... (stopping at {max_items} items)")
break
print(f"Retrieved {count} citation records via pagination.")
print("-" * 40)
print("Example 7: 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"Last Updated: {fields_response.last_data_updated_date}")
print(f"Sample fields: {fields_response.fields[:5]}")