uspto_xml 0.1.0

A library for downloading patent and application XML from the USPTO.
Documentation

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.1.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 or download_application_xml 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(patent_number, xml_path, api_key).await.unwrap();
}

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("9472120", "patent.xml").await.unwrap();
  client.download_application_xml("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.1.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.