Skip to content

Commit a1fcda5

Browse files
committed
variable api domain
1 parent a49f721 commit a1fcda5

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

plotly/plotly/plotly.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,8 @@ def response_handler(cls, response):
900900

901901
@classmethod
902902
def api_url(cls, resource):
903-
# TODO: Variable URL
904-
return 'https://api-local.plot.ly/v2/{}'.format(resource)
903+
return '{}/v2/{}'.format(tools.get_config_file()['plotly_api_domain'],
904+
resource)
905905

906906
@classmethod
907907
def headers(cls):
@@ -924,6 +924,7 @@ def _get_session_username_and_key():
924924
raise exceptions.PlotlyLocalCredentialsError()
925925
return username, api_key
926926

927+
927928
def _send_to_plotly(figure, **plot_options):
928929
"""
929930
"""

plotly/tools.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ def warning_on_one_line(message, category, filename, lineno, file=None, line=Non
4949
'api_key': '',
5050
'stream_ids': []},
5151
CONFIG_FILE: {'plotly_domain': 'https://plot.ly',
52-
'plotly_streaming_domain': 'stream.plot.ly'}}
52+
'plotly_streaming_domain': 'stream.plot.ly',
53+
'plotly_api_domain': 'https://api.plot.ly'}}
5354

5455
try:
5556
os.mkdir(TEST_DIR)
@@ -139,7 +140,9 @@ def reset_credentials_file():
139140

140141
### config tools ###
141142

142-
def set_config_file(plotly_domain=None, plotly_streaming_domain=None):
143+
def set_config_file(plotly_domain=None,
144+
plotly_streaming_domain=None,
145+
plotly_api_domain=None):
143146
"""Set the keyword-value pairs in `~/.plotly/.config`.
144147
145148
"""
@@ -152,6 +155,8 @@ def set_config_file(plotly_domain=None, plotly_streaming_domain=None):
152155
settings['plotly_domain'] = plotly_domain
153156
if isinstance(plotly_streaming_domain, six.string_types):
154157
settings['plotly_streaming_domain'] = plotly_streaming_domain
158+
if isinstance(plotly_api_domain, six.string_types):
159+
settings['plotly_api_domain'] = plotly_api_domain
155160
utils.save_json_dict(CONFIG_FILE, settings)
156161
ensure_local_plotly_files() # make sure what we just put there is OK
157162

@@ -183,7 +188,7 @@ def reset_config_file():
183188

184189
def get_embed(file_owner_or_url, file_id=None, width="100%", height=525):
185190
"""Returns HTML code to embed figure on a webpage as an <iframe>
186-
191+
187192
Plotly uniquely identifies figures with a 'file_owner'/'file_id' pair.
188193
Since each file is given a corresponding unique url, you may also simply
189194
pass a valid plotly url as the first argument.
@@ -262,7 +267,7 @@ def get_embed(file_owner_or_url, file_id=None, width="100%", height=525):
262267

263268
def embed(file_owner_or_url, file_id=None, width="100%", height=525):
264269
"""Embeds existing Plotly figure in IPython Notebook
265-
270+
266271
Plotly uniquely identifies figures with a 'file_owner'/'file_id' pair.
267272
Since each file is given a corresponding unique url, you may also simply
268273
pass a valid plotly url as the first argument.

0 commit comments

Comments
 (0)