diff --git a/datawrapper/__main__.py b/datawrapper/__main__.py index c6818ae..af0a30a 100644 --- a/datawrapper/__main__.py +++ b/datawrapper/__main__.py @@ -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. diff --git a/tests/test_display_urls.py b/tests/test_display_urls.py new file mode 100644 index 0000000..7d45b45 --- /dev/null +++ b/tests/test_display_urls.py @@ -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)