-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathoa_actions_example.py
More file actions
117 lines (98 loc) · 3.57 KB
/
oa_actions_example.py
File metadata and controls
117 lines (98 loc) · 3.57 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
107
108
109
110
111
112
113
114
115
116
117
"""Example usage of pyUSPTO for Office Action Text Retrieval.
Demonstrates the OAActionsClient for searching full-text office action
documents, filtering by various criteria, inspecting section data,
and paginating through results.
"""
import os
from pyUSPTO import OAActionsClient, 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 = OAActionsClient(config=config)
print("-" * 40)
print("Example 1: Search by application number")
print("-" * 40)
response = client.search(patent_application_number_q="11363598")
print(f"Found {response.num_found} office actions for application 11363598.")
for record in response.docs[:3]:
print(f"\n Doc Code: {record.legacy_document_code_identifier}")
print(f" Submission Date: {record.submission_date}")
print(f" Art Unit: {record.group_art_unit_number}")
if record.section:
if record.section.section_102_rejection_text:
print(" Has § 102 rejection text.")
if record.section.section_103_rejection_text:
print(" Has § 103 rejection text.")
print("-" * 40)
print("Example 2: Search by document code (CTNF) and tech center")
print("-" * 40)
response = client.search(
tech_center_q="2800",
legacy_document_code_identifier_q="CTNF",
rows=5,
)
print(f"Found {response.num_found} CTNF office actions in tech center 2800.")
for record in response.docs:
print(
f" App {record.patent_application_number}: "
f"AU {record.group_art_unit_number}, "
f"submitted {record.submission_date}"
)
print("-" * 40)
print("Example 3: Search by submission date range")
print("-" * 40)
response = client.search(
submission_date_from_q="2010-01-01",
submission_date_to_q="2010-12-31",
rows=5,
)
print(f"Found {response.num_found} office actions submitted in 2010.")
print("-" * 40)
print("Example 4: Search with sort")
print("-" * 40)
response = client.search(
tech_center_q="1700",
sort="submissionDate desc",
rows=5,
)
print(f"Found {response.num_found} office actions in tech center 1700 (newest first).")
for record in response.docs:
print(f" {record.submission_date}: {record.invention_title}")
print("-" * 40)
print("Example 5: Inspect section data")
print("-" * 40)
response = client.search(
criteria='id:"9c27199b54dc83c9a6f643b828990d0322071461557b31ead3428885"',
rows=1,
)
if response.docs:
record = response.docs[0]
print(f"Record: {record.id}")
print(f" Patent Number: {record.patent_number}")
print(f" Invention Title: {record.invention_title}")
if record.section:
print(" Section 102 text (first 200 chars):")
for text in record.section.section_102_rejection_text:
if text:
print(f" {text[:200]}...")
print("-" * 40)
print("Example 6: Paginate through results")
print("-" * 40)
max_items = 30
count = 0
for _ in client.paginate(tech_center_q="1700", rows=10):
count += 1
if count >= max_items:
print(f" ... (stopping at {max_items} items)")
break
print(f"Retrieved {count} office action 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]}")