Skip to content

Commit cdbe36f

Browse files
committed
vignette clean up
1 parent 7d67057 commit cdbe36f

File tree

1 file changed

+30
-15
lines changed

1 file changed

+30
-15
lines changed

vignettes/examples.Rmd.orig

+30-15
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,10 @@ knitr::opts_chunk$set(
1414
)
1515
```
1616

17-
## Recent API Change
18-
1917
With the recent [API changes](api-changes.html), the patents endpoint is the main way to retrieve data. The other
2018
endpoints supply additional information. Also note that an API key is required.
2119

22-
## Patents endpoint
20+
## Patent endpoint
2321

2422
Which patents have been cited by more than 500 US patents?
2523

@@ -49,10 +47,6 @@ pv_out$data$assignees$assignee_organization
4947

5048
Where geographically have Microsoft inventors been coming from over the past few years?
5149

52-
Note that the api currently returns no results for "Microsoft Corporation" but will return
53-
"Microsoft Corporation",
54-
"Microsoft Corporation—One Microsoft Way"
55-
5650
```{r}
5751
# Write the query
5852
query <- with_qfuns(
@@ -71,21 +65,44 @@ pv_out <- search_pv(query, fields = inv_fields, all_pages = TRUE, per_page = 100
7165
unnest_pv_data(pv_out$data, "patent_id")
7266
```
7367

74-
Which inventors have Chicago, IL listed as their location on at least one patent.[^1]
68+
## Inventor Endpoint
69+
70+
Which inventor's most recent patent has Chicago, IL listed as their location.
7571

7672
```{r}
7773
pv_out <- search_pv(
78-
query = '{"_and":[{"_text_phrase": {"inventors.inventor_city":"Chicago"}},{"_text_phrase": {"inventors.inventor_state":"IL"}}]}',
79-
endpoint = "patent"
74+
query = '{"_and":[{"_text_phrase": {"inventor_lastknown_city":"Chicago"}},
75+
{"_text_phrase": {"inventor_lastknown_state":"IL"}}]}',
76+
endpoint = "inventor"
8077
)
8178

8279
pv_out
8380

84-
if (pv_out$query_results$total_hits == 0) {
85-
print("something seems to be wrong with the API")
86-
}
81+
```
82+
In the new version of the API, the behavior of this endpoint has changed. See the similar example
83+
on the [legacy inventors endpoint](https://patentsview.org/apis/api-endpoints/inventors) page
84+
for its original behavior.
85+
86+
We could also call the new version of the patent endpoint to find inventors who listed
87+
Chicago, IL as their location when applying for a patent.
88+
89+
```{r}
90+
fields <- c("patent_id", get_fields('patent', groups="inventors"))
91+
fields
92+
93+
query <- '{"_and":[{"_text_phrase": {"inventors.inventor_city":"Chicago"}},
94+
{"_text_phrase": {"inventors.inventor_state":"IL"}}]}'
95+
96+
search_pv(query, fields=fields, endpoint="patent")
97+
8798
```
8899

100+
Note that here all the inventors on a particular patent will be returned, not just the ones whose
101+
location was Chicago, IL. Also see the [Writing Queries Vignette](writing-queries.html) for more readable ways
102+
to write queries.
103+
104+
## Assignee Endpoint
105+
89106
Which assignees have an interest in beer?
90107

91108
```{r}
@@ -94,5 +111,3 @@ search_pv(
94111
endpoint = "patent"
95112
)
96113
```
97-
98-
[^1]: Example taken from https://patentsview.org/apis/api-endpoints/inventors.

0 commit comments

Comments
 (0)