I am trying the following simple code to get JSON from the Stack Exchange API and it gives me the following error:

JSONDecodeError: Expecting value: line 3 column 1 (char 3)

Here is my script:

import requests
import json

r = requests.get(url)


1 Answer 1


That URL is the URL of the documentation page, so you'll get HTML back and not JSON. You'll need to replace it with the URL next to the 'Run' button (right-click and choose Copy Link, it should start with https://api.stackexchange.com/2.3):

enter image description here


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .