Image File Wrapper Example — pyUSPTO 0.2.3.dev1+g2c5d89b38.d20251125 documentation

# Image File Wrapper Example

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