1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
//! 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.
pub use crate::;
/// 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.