Skip to content

Commit 30782e6

Browse files
authored
Merge pull request #374 from palewire/get-data
2 parents 910d74d + a2b8a5e commit 30782e6

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

datawrapper/__main__.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,31 @@ def chart_properties(
336336
)
337337
return None
338338

339+
def chart_data(self, chart_id: str):
340+
"""Retrieve the data stored for a specific chart, table or map, which is typically CSV.
341+
342+
Parameters
343+
----------
344+
chart_id : str
345+
ID of chart, table, or map.
346+
347+
Returns
348+
-------
349+
dict
350+
A dictionary containing the information of the chart, table, or map.
351+
"""
352+
# Request the data endpoint
353+
response = r.get(
354+
url=self._CHARTS_URL + f"/{chart_id}/data",
355+
headers=self._auth_header,
356+
)
357+
358+
# Check if the request was successful
359+
assert response.ok, "Make sure you have the right id and authorization credentials (access_token)."
360+
361+
# Return the data
362+
return response.json()
363+
339364
def update_metadata(
340365
self, chart_id: str, properties: Dict[Any, Any]
341366
) -> Union[Any, None]:

0 commit comments

Comments
 (0)