algorithmic-trading-python icon indicating copy to clipboard operation
algorithmic-trading-python copied to clipboard

Hi, I am getting Jason decoder error, please help

Open Dereklenny opened this issue 3 years ago • 5 comments

image

Dereklenny avatar Jun 14 '21 16:06 Dereklenny

Hi @Dereklenny ,

What Response code do you get when you run the following?:

data = requests.get(api_url)
data

If it doesn't return <Response [200]>, it means there's a problem with the API call.

You can also output the content of the Response as text to see what it contains (see code snippet below). Note that because the ".json()" method is not used it does not try to parse the output to a JSON object and therefore won't generate the error. It does mean that you'd be working with a text object and not a JSON object though.

What do you get when you run the following?:

data = requests.get(api_url)
data.text

dphugo avatar Jun 19 '21 19:06 dphugo

image Dphugo Hi

Thanks for the reply! I got the reply and it seemed to relate to the sandbox mode I have little experience with it

Thank you for your help

Dereklenny avatar Jun 21 '21 18:06 Dereklenny

Hi @Dereklenny ,

A Response of 403 means the iexpais.com server denied the request ([(https://en.wikipedia.org/wiki/HTTP_403])

The "data.text" gives us the detail of why we got a Response of 403. It seems the token you are using is a Production token.

Have you followed the instructions below as the token contained here is for sandbox access? image

Or have you registered on iexapis.com and generated an API token for yourself to trade with? If you have your own API token you would have to point the URL as shown in the response you got in "Out [6]". Note that you might incur costs if you do. I'm not familiar with iexpais.com's cost structure.

dphugo avatar Jun 22 '21 06:06 dphugo

Dehugo

Hi

Thank you so much for the reply

it is my fault, I used the production token ( not sure the cost)

it works for now.

I will continue learn the rest of code

Thanks again

image

The real

Dereklenny avatar Jun 22 '21 15:06 Dereklenny

@Dereklenny please close the issue if this has been solved

datatalking avatar Jul 19 '21 02:07 datatalking