✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
🐇 Announcing Dash VTK for 3d simulation graphics. Check out the March webinar.

Errors accessing plotly API


I’ve just started using the Python library for Plotly (v4.4.1) with Python 3.6.

I am attempting to build a candlestick chart based on the tutorial here

A gist with the actual code I am using can be found here

When I run the code it takes several minutes then fails. Stepping through the plotly code in a debugger it seems that the time taken is in background API calls to plotly. These are as follows:

Multiple HTTP GET requests to https://api.plot.ly/v2/files/lookup - each one returns a 500 status code and HTML to generate the attached screenshot. It takes ages as it uses exponential back off to a 16 second delay which is used several times before it gives up.

Once that part has failed it then attempts a HTTP POST to https://api.plot.ly/v2/grids which fails with a 401 response (not authorised)

So I guess my questions are:

  1. is there any way I can disable the lookup requests as they just error?
  2. do I need to configure some kind of authentication to get the POST request to work?

Ideally I’d rather not use libraries that require online access (e.g running on firewalled servers etc) - is there any way I can just disable all the API access?

ok, so I found a solution to my problem - when I let my program run through, the error message produced is:

chart_studio.exceptions.PlotlyRequestError: Authentication credentials were not provided.

I Googled this error and there were suggestions to run plotly in offline mode by replacing:

import chart_studio.plotly as py


import plotly.offline as py

then use py.plot instead of py.iplot

It would be nice if there was a clearer explanation for working in online/offline mode. If anyone could link me to the docs on this, it would be appreciated.

Hi @madeye, welcome to the forum. The example uses the old (plotly <= 3) syntax, which is not compatible with plotly 4+. You should make sure to use a recent version of plotly (>= 4) and for a candlestick example you can use the official documentation https://plot.ly/python/candlestick-charts/

Hi Emmanuelle,

thanks for getting back to me!

I had managed to construct the candlestick charts in your linked docs first. However the tutorial I was following subsequently included some advanced features that were not included in the main docs on candlestick charts (namely volume histogram and Bolinger bands). Thanks to you, I now realise that this was based on outdated syntax (although it can be made to work using the approach I described).

I will attempt to re-create the tutorial using the latest syntax

Plotly v4 Candlestick Chart with Bollinger bands in Python (based on original tutorial by JackP)