Patent data for an R script
Use the rOpenSci patentsview package and point it at PatentRef. The development version on GitHub reads options(patentsview.base_url = "https://patentref.io") or the PATENTSVIEW_BASE_URL variable, so your search_pv() calls stay the same. Put a free PatentRef key in PATENTSVIEW_API_KEY.
How to set it up
- Get a free key at https://patentref.io/api/v1/meta/signup/.
- Install the development version of patentsview from GitHub. The base URL setting is not in the CRAN release yet.
- Set the key and the base URL, then call search_pv() as before.
# install.packages("pak")
pak::pak("ropensci/patentsview")
library(patentsview)
Sys.setenv(PATENTSVIEW_API_KEY = "YOUR_KEY")
options(patentsview.base_url = "https://patentref.io")
res <- search_pv(
query = qry_funs$eq(patent_id = "10905426"),
fields = c("patent_id", "patent_title", "patent_date")
)
res$data$patents
On the CRAN release, version 1.0.0, replace the package's URL function for the session instead:
library(patentsview)
Sys.setenv(PATENTSVIEW_API_KEY = "YOUR_KEY")
assignInNamespace("get_base", function(endpoint) sprintf("https://patentref.io/api/v1/%s/", endpoint), ns = "patentsview")
For PatentRef's own routes, such as the claim tree, use httr2 with the same key:
library(httr2)
tree <- request("https://patentref.io/api/v1/structure/claims/10034028/") |>
req_headers("X-Api-Key" = "YOUR_KEY") |>
req_perform() |>
resp_body_json()
What you get
- search_pv() answers from PatentRef with the same queries, fields and paging.
- Results as data frames, for patents, inventors, assignees and the other endpoints the package knows.
- US patents granted from 1976 on.
- With all_pages = TRUE, the package walks every page of a result for you.
- The package waits and tries again when the API answers 429.
Good to know
- The base URL setting takes the scheme and host: https://patentref.io, without /api/v1/. The option wins over the environment variable.
- A PatentsView key does not work on PatentRef. Every API call needs a PatentRef key.
- A free key allows 1,000 requests a month and 45 a minute. Each page of a result is one request.
- Pre-grant publication endpoints answer 501 in the current build.
- The patentsview package is an rOpenSci project. PatentRef does not maintain it.
- Record pages, such as patentref.io/p/6285999/, need no sign-up.
FAQ
Is the base URL setting on CRAN?
Not yet. CRAN has version 1.0.0. Install the development version from GitHub, or use the assignInNamespace line with version 1.0.0.
Do I have to change my search_pv() queries?
No. PatentRef answers the same q, f, s and o grammar, so the same calls work.
Can I skip the package and use httr2?
Yes. Send GET requests to https://patentref.io/api/v1/ with your key in the X-Api-Key header.
Related pages
More questions
PatentRef is an independent service and is not affiliated with the USPTO. Answers describe the text as the USPTO printed it; none is a legal conclusion.