Skip to main content
 
 
 
IN THIS SECTION
5 posts
lucy wang
Last seen: 08/09/2021 - 09:45
Joined: 03/10/2021 - 11:11
Problems using API wrapper

Dear all,

 I try to use the API wrapper to download a large amount of data (https://github.com/mustberuss/PatentsView-APIWrapper to do ). After customizing  sample_config.cfg file and running the code, I got the following error message:

---------------------------------------------------------------------------

JSONDecodeError Traceback (most recent call last)

~/PatentsView-APIWrapper/api_wrapper.py in <module>()

113 print("File not found: ", sys.argv[1])

114

--> 115 query(sys.argv[1])

~/PatentsView-APIWrapper/api_wrapper.py in query(configfile)

26 directory = json.loads(parser.get(q, 'directory'))

27 input_type = json.loads(parser.get(q, 'input_type'))

---> 28 fields = json.loads(parser.get(q, 'fields'))

29

30

/ihome/crc/install/python/miniconda3-3.7/lib/python3.7/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)

346 parse_int is None and parse_float is None and

347 parse_constant is None and object_pairs_hook is None and not kw):

--> 348 return _default_decoder.decode(s)

349 if cls is None:

350 cls = JSONDecoder

/ihome/crc/install/python/miniconda3-3.7/lib/python3.7/json/decoder.py in decode(self, s, _w)

335

336 """

--> 337 obj, end = self.raw_decode(s, idx=_w(s, 0).end())

338 end = _w(s, end).end()

339 if end != len(s):

/ihome/crc/install/python/miniconda3-3.7/lib/python3.7/json/decoder.py in raw_decode(self, s, idx)

353 obj, end = self.scan_once(s, idx)

354 except StopIteration as err:

--> 355 raise JSONDecodeError("Expecting value", s, err.value) from None

356 return obj, end JSONDecodeError: Expecting value: line 1 column 135 (char 134)

__________________________________________________________________________

I was unable to figure out what might be the problem here? Any advice would be much appreciated!

Lucy

Russ
Last seen: 03/15/2024 - 23:34
Joined: 11/14/2017 - 22:15
HEY, THAT&amp;#039;S ME

Hi Lucy,

That's my fork of https://github.com/CSSIP-AIR/PatentsView-APIWrapper    They pushed changes today for the url change so my repo is behind. Could you try pulling their latest code?  Also are you passing the config file on the command line?  Here's how I run one of my configs:  python api_wrapper.py wd_plants.cfg  By the way the api itself is in a couple of projects under CSSIP-AIR. 

Russ

lucy wang
Last seen: 08/09/2021 - 09:45
Joined: 03/10/2021 - 11:11
THANKS VERY MUCH! I PULLED…

Thanks very much! I pulled their lastest code and found that the problem actually lies in the syntax error when writing query criteria: when I use "_and" for the combination query I did not use {} for each condition. I fixed that and now the code is running. I should really check the syntax before asking for help here! 

Lucy

Russ
Last seen: 03/15/2024 - 23:34
Joined: 11/14/2017 - 22:15
NO WORRIES!

No worries!  I should have mentioned earlier that you can chain your wrapper queries together.  Check out https://patentsview.org/forum/9/topic/159  where the second query's input is the output from the first query.

lucy wang
Last seen: 08/09/2021 - 09:45
Joined: 03/10/2021 - 11:11
THANKS! IT IS NICE TO KNOW…

Thanks! It is nice to know about this feature!