The Python Wrapper

This has nothing to do with a snake in a hoodie laying down rhythmic rhymes, that would be Python The Rapper :-) The same people who wrote the patentsview api also wrote a python wrapper that produces a csv file. All you need to do is download the code and dependencies (instructions provided in the link and below) and write a configuration file for your query or queries (more than one query can be specified in a configuration file).

Here is a configuration file that will execute three queries.
[QUERY1]
entity = "patents"
input_file = "patents.txt"
directory = "C:/Users/Russ/mygit/my-wrapper"  
input_type = "patent_number"
fields = ["patent_number", "assignee_id", "assignee_organization", "assignee_first_name", "assignee_last_name", "assignee_city", "assignee_country"]
criteria = {"_not":{"assignee_id":""}}

[QUERY2]
entity = "patents"
input_file = "patents.txt"
directory = "C:/Users/Russ/mygit/my-wrapper"  
input_type = "patent_number"
fields = ["assignee_id"]
criteria = {"_not":{"assignee_id":""}}

[QUERY3]
entity = "assignees"
input_file = "QUERY2.csv"
directory = "C:/Users/Russ/mygit/my-wrapper"  
input_type = "assignee_id"
fields = ["patent_title","patent_number", "assignee_id", "assignee_organization", "assignee_first_name", "assignee_last_name"]

where patents.txt used in QUERY1 and QUERY2 contains the patent numbers, one per line, whose assignees we'd like to retrieve.  Ex:
10011839
9997705
5342415
5376143

QUERY1 will produce QUERY1.csv containing the 7 fields specified in its "fields" line. QUERY2 is the same as QUERY1 except that QUERY2.csv will only contain the assignee_id (fields = ["assignee_id"]). QUERY2.csv then becomes input in QUERY3, how cool is that! QUERY2 found the assignee_ids the api uses for the patents we specified and QUERY3 will find all patents associated with those assignee_ids. QUERY3.csv will then contain the fields specified in its fields= line.

The patentsview query language used in the optional criteria line is explained here. Note that more than one criteria can be specified per query, see the examples on the python wrapper page. The query langage page also has links to the api's endpoints, showing what fields can be retrieved and/or queried for each of the api's 7 endpoints patents, inventors, assignees, locations, cpc_subsections, uspc_mainclasses, nber_subcategories. The endpoint for a query is specied in the entity configuration line.

QUERY1.csv contains
patent_number,assignee_id,assignee_organization,assignee_first_name,assignee_last_name,assignee_city,assignee_country
10011839,org_Iqb7att9wxyj3Pr1I3lk,William Marsh Rice University,None,None,Houston,US
5342415,per_fz8KN6xKptzaAR9Z8Fa9,None,Eric,Wasinger,Wichita,US
5376143,per_fz8KN6xKptzaAR9Z8Fa9,None,Eric,Wasinger,Adamsville,US
9997705,org_Iqb7att9wxyj3Pr1I3lk,William Marsh Rice University,None,None,Houston,US

QUERY2.csv contains
assignee_id
org_Iqb7att9wxyj3Pr1I3lk
per_fz8KN6xKptzaAR9Z8Fa9

QUERY2.csv has 439 lines, starting with these 6
patent_title,patent_number,assignee_id,assignee_organization,assignee_first_name,assignee_last_name
Adaptive power system,7385374,org_Iqb7att9wxyj3Pr1I3lk,William Marsh Rice University,None,None
Addressable SiOX memory array with incorporated diodes,9385163,org_Iqb7att9wxyj3Pr1I3lk,William Marsh Rice University,None,None
Aliphatic amine based nanocarbons for the absorption of carbon dioxide,8636830,org_Iqb7att9wxyj3Pr1I3lk,William Marsh Rice University,None,None
Aliphatic amine based nanocarbons for the absorption of carbon dioxide,9034085,org_Iqb7att9wxyj3Pr1I3lk,William Marsh Rice University,None,None
All optical nanoscale sensor,8045152,org_Iqb7att9wxyj3Pr1I3lk,William Marsh Rice University,None,None

Notes on installing git and python