1

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
url='https://api.stackexchange.com/docs/questions#order=desc&sort=activity&filter=default&site=stackoverflow&run=true'

r = requests.get(url)

r.json()

1 Answer 1

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

0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.