1"""Example usage of pyUSPTO for IFW data.
2
3This example demonstrates how to use the PatentDataClient to interact with the USPTO Patent Data API.
4It shows how to retrieve IFW based on various identifying values.
5"""
6
7import json
8import os
9
10from pyUSPTO.clients.patent_data import PatentDataClient
11
12api_key = os.environ.get("USPTO_API_KEY", "YOUR_API_KEY_HERE")
13if api_key == "YOUR_API_KEY_HERE":
14 raise ValueError(
15 "WARNING: API key is not set. Please replace 'YOUR_API_KEY_HERE' or set USPTO_API_KEY environment variable."
16 )
17
18client = PatentDataClient(api_key=api_key)
19
20
21print("\nBeginning API requests with configured client:")
22
23print("\nGet IFW Based on Application Number ->")
24application_number = "14412875"
25app_no_ifw = client.get_IFW_metadata(application_number=application_number)
26if app_no_ifw and app_no_ifw.application_meta_data:
27 print(f"Title: {app_no_ifw.application_meta_data.invention_title}")
28 print(f" - IFW Found based on App No: {application_number}")
29
30
31print("\nGet IFW Based on Patent Number ->")
32patent_number = "10765880"
33pat_no_ifw = client.get_IFW_metadata(patent_number=patent_number)
34if pat_no_ifw and pat_no_ifw.application_meta_data:
35 print(f"Title: {pat_no_ifw.application_meta_data.invention_title}")
36 print(f" - IFW Found based on Pat No: {patent_number}")
37
38
39print("\nGet IFW Based on Publication Number ->")
40publication_number = "*20150157873*"
41pub_no_ifw = client.get_IFW_metadata(publication_number=publication_number)
42if pub_no_ifw and pub_no_ifw.application_meta_data:
43 print(f"Title: {pub_no_ifw.application_meta_data.invention_title}")
44 print(f" - IFW Found based on Pub No: {publication_number}")
45
46
47print("\nGet IFW Based on PCT App Number ->")
48PCT_app_number = "PCT/US2008/12705"
49pct_app_no_ifw = client.get_IFW_metadata(PCT_app_number=PCT_app_number)
50if pct_app_no_ifw and pct_app_no_ifw.application_meta_data:
51 print(f"Title: {pct_app_no_ifw.application_meta_data.invention_title}")
52 print(f" - IFW Found based on PCT App No: {PCT_app_number}")
53
54
55print("\nGet IFW Based on PCT Pub Number ->")
56PCT_pub_number = "*2009064413*"
57pct_pub_no_ifw = client.get_IFW_metadata(PCT_pub_number=PCT_pub_number)
58if pct_pub_no_ifw and pct_pub_no_ifw.application_meta_data:
59 print(f"Title: {pct_pub_no_ifw.application_meta_data.invention_title}")
60 print(f" - IFW Found based on PCT Pub No: {PCT_pub_number}")
61
62
63print("\nNow let's download the Patent Publication Text -->")
64if app_no_ifw and app_no_ifw.pgpub_document_meta_data:
65 pgpub_archive = app_no_ifw.pgpub_document_meta_data
66 print(json.dumps(pgpub_archive.to_dict(), indent=2))
67 download_path = "./download-example"
68 file_path = client.download_archive(
69 printed_metadata=pgpub_archive, destination_path=download_path, overwrite=True
70 )
71 print(f"-Downloaded document to: {file_path}")
72
73print("\nNow let's download the Patent Grant Text -->")
74if app_no_ifw and app_no_ifw.grant_document_meta_data:
75 grant_archive = app_no_ifw.grant_document_meta_data
76 print(json.dumps(grant_archive.to_dict(), indent=2))
77 download_path = "./download-example"
78 file_path = client.download_archive(
79 printed_metadata=grant_archive, destination_path=download_path, overwrite=True
80 )
81 print(f"-Downloaded document to: {file_path}")