Skip to content

Commit

Permalink
Merge pull request #402 from palewire/display-urls
Browse files Browse the repository at this point in the history
Add display urls endpoint
  • Loading branch information
chekos authored Feb 1, 2024
2 parents d49ef8e + fe38564 commit b411496
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
15 changes: 15 additions & 0 deletions datawrapper/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1099,6 +1099,21 @@ def export_chart(
logger.debug(f"File exported at {_filepath}")
return _filepath

def get_chart_display_urls(self, chart_id: str) -> list[dict]:
"""Get the URLs for the published chart, table or map.
Parameters
----------
chart_id : str
ID of chart, table, or map.
Returns
-------
list[dict]
A list of dictionaries containing the URLs for the published chart, table, or map.
"""
return self.get(f"{self._CHARTS_URL}/{chart_id}/display-urls")

def get_iframe_code(self, chart_id: str, responsive: bool = False) -> str:
"""Returns a chart, table, or map's iframe embed code.
Expand Down
14 changes: 14 additions & 0 deletions tests/test_display_urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
"""Test oembed functions."""
from datawrapper import Datawrapper


def test_get_chart_display_urls():
"""Test get_oembed function."""
dw = Datawrapper()

# Get display urls for a chart
data = dw.get_chart_display_urls("WpAbK")

# Verify it contains a list of dictionarys
assert isinstance(data, list)
assert isinstance(data[0], dict)

0 comments on commit b411496

Please sign in to comment.