Fetch File History from USPTO
0
File Wrapper Fetcher
edited
1# Project Blueprint: Secure Patent File History Fetcher
2
3### Project Objective
4
5Create a lightweight, local web application where a user inputs an 8-digit USPTO application number and instantly views the official, public Image File Wrapper (IFW) transaction history and direct PDF download links.
6
7---
8
9### The Architecture: Why We Need a Backend
10
11The programmer must understand that this cannot be built entirely in the browser using frontend JavaScript.
12
13* **The Security Rule:** The USPTO requires a secret **API Key** to access their servers. If we put this key in the frontend HTML/JavaScript, anyone can right-click the page, click "Inspect Element," and steal it.
14* **The Solution:** Use a **Client-Server model**. The frontend browser collects the application number and sends it to our local Python server. The Python server securely attaches the API key, talks to the USPTO, receives the data, and passes it back to the browser safely.
15
16---
17
18### Step-by-Step畅 Implementation Guide for the Programmer
19
20#### 1. Environment & Tools
21
22* **Language:** Python 3
23* **Libraries to Install:** `requests` (for handling HTTP communication) and `flask` (a lightweight web framework to host the app).
24* **Prerequisites:** Register a free developer account at `data.uspto.gov` and generate an API key for the **Patent File Wrapper API**.
25
26#### 2. Building the Backend (`app.py`)
27
28The programmer needs to write a Flask script that sets up two distinct "routes" (URLs):
29
30* **Route 1 (`/`):** Serves a basic HTML webpage to the browser when the user opens the app.
31* **Route 2 (`/get-history`):** An API endpoint that waits for an application number from the frontend.
32
33When Route 2 receives an application number, it must execute a `GET` request using the `requests` library to the official USPTO production endpoint:
34
35```text
36https://api.uspto.gov/api/v1/patent/applications/{APP_NUMBER}/documents
37
38```
39
40The script must securely inject the developer's API key into the HTTP request headers using the custom key designation required by the USPTO (`X-API-KEY`).
41
42#### 3. Handling the Data Payload
43
44The USPTO server returns a status code of `200 OK` and a structured data format called a **JSON object**. The programmer will need to parse this object:
45
46* Look for a main data key called `documentBag` which holds an array (list) of dictionaries.
47* Each dictionary in that list represents a file history document and contains key-value pairs the programmer needs to display: `officialDate`, `documentCodeDescriptionText`, and `downloadUrl` (the direct link to the USPTO PDF file).
48
49#### 4. Building the Frontend (HTML/JavaScript)
50
51Inside the Flask application, the programmer will design a clean, simple user interface using standard HTML and CSS:
52
53* An **Input Box** with a placeholder text asking for an 8-digit application number.
54* A **"Search" Button** that triggers a JavaScript function when clicked.
55* A **Results Display Box** (like a `<div>` or `<pre>` tag) to show the incoming file log.
56* **The JavaScript Logic:** Use the modern `fetch()` API to asynchronously send the input box value to the Python server's `/get-history` route, listen for the JSON response, and dynamically update the webpage text without requiring a full page refresh.
57
58---
59
60### Expected Outcome & Extension Challenge
61
62When the programmer runs `python app.py`, it will host a local server at `http://127.0.0.1:5000`. Typing a published application number (like `14412875`) will display a clean, chronological list of every Office Action and response issued during prosecution.