Datawrapper Python Wrapper

raw JSON →
2.0.16 verified Fri May 01 auth: no python

A lightweight Python wrapper for the Datawrapper API, supporting chart creation, data upload, publishing, and export. Current version 2.0.16, requires Python >=3.10. Active development with frequent releases.

pip install datawrapper
error ModuleNotFoundError: No module named 'datawrapper'
cause The package is installed under the name 'datawrapper' but imported as 'datawrapper' (correct). If you see this, the package is not installed.
fix
Run: pip install datawrapper
error TypeError: 'NoneType' object is not subscriptable
cause A method returned None because of an invalid chart_id or missing data.
fix
Verify that the chart exists and that you have provided valid data using add_data() before calling export or publish.
error datawrapper.core.DatawrapperError: 401 - Unauthorized
cause Invalid or missing API access token.
fix
Set the DW_ACCESS_TOKEN environment variable or pass it to the constructor: Datawrapper(access_token='your_token_here')
error AttributeError: module 'datawrapper' has no attribute 'Datawrapper'
cause Importing incorrectly. The class is directly under the 'datawrapper' module.
fix
Use: from datawrapper import Datawrapper
breaking v2.0.0 changed the API completely. Old code using version 1.x is not compatible.
fix Migrate to new constructor: Datawrapper(access_token='...') and use methods like create_chart, add_data, publish_chart.
gotcha The chart_id parameter in move_chart changed from int to str in v2.0.13.
fix Always pass chart_id as a string, not an integer.
gotcha Export methods (export_png, export_pdf, export_svg) have simplified parameters in v2.0.15; older parameter names may break.
fix Check the new signature: export_png(chart_id, unit='px', width=800) etc. Remove deprecated parameters like 'full_vector'.

Initialize the client with API token and create a simple bar chart.

from datawrapper import Datawrapper
dw = Datawrapper(access_token=os.environ.get('DW_ACCESS_TOKEN', ''))
chart = dw.create_chart(title='Test Chart', chart_type='d3-bars')
print(chart['id'])