uspto_xml

Crates.iouspto_xml
lib.rsuspto_xml
version0.2.0
created_at2025-12-10 01:59:55.482384+00
updated_at2025-12-22 07:47:16.918958+00
descriptionA library for downloading patent and application XML from the USPTO.
homepage
repositoryhttps://github.com/jmicheli/uspto_xml/
max_upload_size
id1977182
size78,894
Joseph Micheli (JMicheli)

documentation

README

USPTO XML

A Rust client for downloading XML from the USPTO's Open Data Portal API. It provides a convenient way to fetch patent and patent application XML documents.

Installation

The library can be installed using cargo add uspto_xml or by adding the following to your Cargo.toml file:

[dependencies]
uspto_xml = "0.2.0"

Usage

To use this library, you will need a USPTO API Key. Instructions for obtaining a key are available at the USPTO's Open Data Portal getting started page.

Using the Asynchronous Client

The default client is asynchronous and designed to work with runtimes like tokio.

If performing a one-off download, the easiest approach is to use the download_patent_xml_to_file or download_application_xml_to_file functions.

Note that the patent number or application number should be provided without any punctuation (e.g., commas) or country code (e.g., the "US" that precedes a patent number). This library only supports downloading US patents and applications.

#[tokio::main]
async fn main() {
  let patent_number = "9472120";
  let xml_path = "patent.xml";
  let api_key = "YOUR_USPTO_API_KEY";

  uspto_xml::download_patent_xml_to_file(patent_number, xml_path, api_key).await.unwrap();
}

The download_patent_xml and download_application_xml functions are also provided if you want to recieve XML as a String without writing it anywhere.

If you intend to make multiple requests, you can avoid re-creating the client for each one by instead creating a UsptoClient and only dropping it once you have finished downloading XML.

#[tokio::main]
async fn main()  {
  let client = uspto_xml::UsptoClient::new("YOUR_USPTO_API_KEY").unwrap();
  client.download_patent_xml_to_file("9472120", "patent.xml").await.unwrap();
  client.download_application_xml_to_file("16554391", "application.xml").await.unwrap();
}

Using the Blocking Client

If you prefer to use a synchronous client that blocks when downloading, enable the blocking feature:

[dependencies]
uspto_xml = { version = "0.2.0", features = ["blocking"] }

The blocking functionality is available in uspto_xml::blocking. The pattern is exactly the same, except that there is no need to await blocking calls.

License

This library is licensed under the Apache License v2.0. See LICENSE.txt for more information.

Commit count: 0

cargo fmt