Skip to content

Commit ff362ce

Browse files
committed
Merge pull request #201 from plotly/update-image-endpoint
Move from genimage —> v2/images/
2 parents 7d27874 + 5139385 commit ff362ce

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

plotly/plotly/plotly.py

+9-11
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import six
2424
import base64
2525
import requests
26+
from requests.auth import HTTPBasicAuth
2627

2728
if sys.version[:1] == '2':
2829
from urlparse import urlparse
@@ -586,25 +587,22 @@ def get(figure_or_data, format='png', width=None, height=None):
586587
credentials = get_credentials()
587588
validate_credentials(credentials)
588589
username, api_key = credentials['username'], credentials['api_key']
589-
headers = {'plotly-username': username,
590-
'plotly-apikey': api_key,
591-
'plotly-version': version.__version__,
592-
'plotly-platform': 'python'}
593-
594-
payload = {
595-
'figure': figure,
596-
'format': format
597-
}
590+
headers = {'Plotly-Version': version.__version__,
591+
'Content-Type': 'application/json',
592+
'Plotly-Client-Platform': 'python'}
598593

594+
payload = {'figure': figure, 'format': format}
599595
if width is not None:
600596
payload['width'] = width
601597
if height is not None:
602598
payload['height'] = height
603599

604-
url = get_config()['plotly_domain'] + "/apigenimage/"
600+
url = _api_v2.api_url('images/')
601+
605602
res = requests.post(
606603
url, data=json.dumps(payload, cls=utils.PlotlyJSONEncoder),
607-
headers=headers, verify=get_config()['plotly_ssl_verification']
604+
headers=headers, verify=get_config()['plotly_ssl_verification'],
605+
auth=HTTPBasicAuth(username, api_key)
608606
)
609607

610608
headers = res.headers

0 commit comments

Comments
 (0)