API Query Syntax - JSON object could not be decoded

59 views Asked by At

This relates to the Patentsview.org API.
http://www.patentsview.org/api/uspc.html#field_list

I would like to modify my current query to limit itself to one or more USPC IDs (US patent classification) I am using id=348 for my test case.

Here is a query I have that works:

PATENTS_API_URL_TEMPLATE = 'http://www.patentsview.org/api/patents/query?q={%22_text_any%22:{%22patent_abstract%22:%22term_placeholder%22}}&f=[%22patent_number%22,%22patent_date%22,%22inventor_last_name%22,%22patent_abstract%22]'

The above query searches for the term_placeholder anywhere in the text and returns the patent number, data, inventors last name, and abstract.

I don't care about the date and name. I only care about the patent number and abstract. But I also want to limit it to one or more patent classes.

I tried the following:

PATENTS_API_URL_TEMPLATE = 'http://www.patentsview.org/api/uspc_mainclasses/query?q={%22_and%22:[{%22_text_any%22:{%22patent_abstract%22:%22term_placeholder%22}},{%22uspc_mainclass_id%22:%22348%22}}]}&f=[%22patent_number%22,%22patent_abstract%22]'

The error I get is ValueError: No JSON object could be decoded.

I was using the following example provided by Patentsview:

http://www.patentsview.org/api/uspc_mainclasses/query?q={"_and":[{"_contains":{"assignee_organization":"Census"}},{"_gte":{"patent_date":"2000-01-01"}},{"_lte":{"patent_date":"2010-12-31"}},{"_contains":{"uspc_mainclass_title":"Electricity"}}]}&f=["inventor_id","inventor_first_name","inventor_last_name"]

I replaced the double quotes with %22, switched from api/patents to api/uspc_mainclasses, removed the name and date fields, and otherwise tried to follow the example.

What am I doing wrong? Thanks!

1

There are 1 answers

0
mustberuss On

You just have an extra } after the 348". Without it the api returns the json you are looking for

[https://api.patentsview.org/uspc_mainclasses/query?q={"_and":\[{"_text_any":{"patent_abstract":"term_placeholder"}},{"uspc_mainclass_id":"348"}\]}&f=\["patent_number","patent_abstract"\]][1]

You can search multiple classes by changing the uspc_mainclass_id to an array

[https://api.patentsview.org/uspc_mainclasses/query?q={"_and":\[{"_text_any":{"patent_abstract":"term_placeholder"}},{"uspc_mainclass_id":\["348","343"\]}\]}&f=\["patent_number","patent_abstract"\]][2]

Note that the uspc classifications stopped being used by the patent office in June 2015. Your query won't return results more recent that than. You'll need to use the cpc classification fields like cpc_group_id if you want to do classification searches that return more recent results.

  [1]: https://api.patentsview.org/uspc_mainclasses/query?q=%7B%22_and%22:[%7B%22_text_any%22:%7B%22patent_abstract%22:%22term_placeholder%22%7D%7D,%7B%22uspc_mainclass_id%22:%22348%22%7D]%7D&f=[%22patent_number%22,%22patent_abstract%22]
  [2]: https://api.patentsview.org/uspc_mainclasses/query?q=%7B%22_and%22:[%7B%22_text_any%22:%7B%22patent_abstract%22:%22term_placeholder%22%7D%7D,%7B%22uspc_mainclass_id%22:[%22348%22,%22343%22]%7D]%7D&f=[%22patent_number%22,%22patent_abstract%22]