Python Forum
Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
OMDB API KEY format
#1
Hello everyone,
I found a tutorial at IMDB. The part I am having the problem at is here:

with open('APIkeys.json') as f:
    keys = json.load(f)
    omdbapi = keys['OMDBapi']
These are the errors I am getting:

JSONDecodeError                           Traceback (most recent call last)
<ipython-input-10-9df4192cbddf> in <module>()
      1 with open('APIkeys.json')as f:
----> 2     keys = json.load(f)
      3     omdbapi = keys['OMDBapi']
      4 

~\Anaconda3\lib\json\__init__.py in load(fp, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
    294         cls=cls, object_hook=object_hook,
    295         parse_float=parse_float, parse_int=parse_int,
--> 296         parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
    297 
    298 

~\Anaconda3\lib\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

~\Anaconda3\lib\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):

~\Anaconda3\lib\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 1 (char 0)


Could it be that I do not have the correct information in my APIKeys.json file. I am not sure what to put in that file. Here is the link that was given to me when I got my key from OMDB website:
OMDb API: http://www.omdbapi.com/?i=tt3896198&apikey=xxxxxxxx

I am sure I am not using the API correctly but cannot find anywhere anything that makes sense to me. Yes, I am a newbie. Thank you for any help. :)
Reply
#2
Please post actual error traceback, unmodified. It contains valuable information.
Reply
#3
http://www.omdbapi.com/apikey.aspx
It looks this is the form where you need to request the key. I think it will be emailed to you.
In the repo there is this file
https://github.com/tirthajyoti/Web-Datab...ample.json
I guess this is sample json file (rename it accordingly). Note that it has thwo API keys - one for OMDB API and one for weatherapi. You need to replace the value 17cdc959 with your key
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#4
LarZ60+

I am using Jupyter notebook, I coped exactly what was no the screen. Please let me know if I should have done it a different way.

buran:
Thank you, it looks like the information you gave me is working so far.
Reply
#5
Quote:I am using Jupyter notebook, I coped exactly what was no the screen. Please let me know if I should have done it a different way.
No that's right for Jupyter.
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020