uspto_xml 0.1.0

A library for downloading patent and application XML from the USPTO.
Documentation
//! A Rust client for downloading XML from the USPTO's Open Data Portal API.
//!
//! This library provides a convenient way to fetch patent and patent application XML documents.
//!
//! # Installation
//!
//! Add the following to your `Cargo.toml` file:
//!
//! ```toml
//! [dependencies]
//! uspto_xml = "0.1.0"
//! ```
//!
//! # Usage
//!
//! A USPTO API Key is required. Instructions for obtaining a key are available at the
//! [USPTO Open Data Portal](https://data.uspto.gov/apis/getting-started).
//!
//! ## Asynchronous Client
//!
//! The default client is asynchronous and designed to work with runtimes like `tokio`.
//!
//! ```rust,no_run
//! # use uspto_xml::download_patent_xml;
//! #[tokio::main]
//! async fn main() {
//!     let patent_number = "9472120";
//!     let xml_path = "patent.xml";
//!     let api_key = "YOUR_USPTO_API_KEY";
//!
//!     download_patent_xml(patent_number, xml_path, api_key).await.unwrap();
//! }
//! ```
//!
//! ## Blocking Client
//!
//! To use the synchronous client, enable the `blocking` feature:
//!
//! ```toml
//! [dependencies]
//! uspto_xml = { version = "0.1.0", features = ["blocking"] }
//! ```
//!
//! The blocking functionality is available in the [`blocking`] module.

#![warn(clippy::pedantic)]
#![warn(clippy::nursery)]
#![allow(clippy::must_use_candidate, clippy::missing_errors_doc)]

mod asynchronous;
#[cfg(feature = "blocking")]
pub mod blocking;
mod error;
mod uspto_data;

pub use crate::{
  asynchronous::{UsptoClient, download_application_xml, download_patent_xml},
  error::UsptoApiError,
};

/// The user agent indicated to the USPTO when making a request.
const USER_AGENT_STR: &str = "rust_uspto_api/0.1.0";

/// The USPTO API endpoint that we use to search for patent numbers.
const USPTO_SEARCH_ENDPOINT: &str = "https://api.uspto.gov/api/v1/patent/applications/search";

/// Formats a URL for accessing an application directly.
fn get_application_endpoint(application_number: &str) -> String {
  format!(
    "https://api.uspto.gov/api/v1/patent/applications/{application_number}/associated-documents"
  )
}