Main Client

The main Datawrapper client provides methods for interacting with the Datawrapper API.

class datawrapper.Datawrapper(access_token=None)[source]

Bases: object

Handles working with the Datawrapper API.

Your main interface for configuring Datawrapper, creating, editing and publishing charts, maps and tables.

account_info() dict[source]

A deprecated method for calling get_my_account.

add_data(chart_id: str, data: DataFrame | str) bool[source]

Add data to a specified chart.

Deprecated since version Use: the object-oriented chart classes instead (e.g., BarChart, LineChart). This method will be removed in a future version.

Parameters:
  • chart_id (str) – ID of chart, table or map to add data to.

  • data (pd.DataFrame | str) – A pandas dataframe containing the data to be added or a string that contains the data.

Returns:

True if the data was added successfully.

Return type:

bool

add_json(chart_id: str, data: Any) bool[source]

Add JSON data to a specified chart.

Can be used to add point, area and line markers to a locator map or other chart.

Parameters:
  • chart_id (str) – ID of chart, table or map to add data to.

  • data (Any) – JSON data to add to the chart.

Returns:

True if the data was added successfully.

Return type:

bool

add_workspace_team_members(workspace_slug: str, team_id: str, user_ids: list[int], role: str = 'member') bool[source]

Add one or multiple users to a workspace team.

Parameters:
  • workspace_slug (str) – Slug of workspace the team belongs to.

  • team_id (str) – ID of team to add users to.

  • user_ids (list[int]) – Array of user IDs to add to the team.

  • role (str, optional) – Role to assign to the users in the team. One of “manager” or “member”. By default “member”.

Returns:

True if the users were added successfully.

Return type:

bool

chart_data(chart_id: str)[source]

A deprecated method of the get_data method.

chart_properties(chart_id: str) dict[source]

A deprecated method of the get_chart method.

copy_chart(chart_id: str) dict[source]

Copy one of your charts, tables, or maps and create a new editable copy.

Deprecated since version Use: the object-oriented chart classes instead (e.g., BarChart, LineChart). This method will be removed in a future version.

Parameters:

chart_id (str) – ID of chart, table, or map.

Returns:

A dictionary containing the information of the chart, table, or map.

Return type:

dict

create_api_token(comment: str, scopes: list[str]) dict[source]

Create a new API Token.

Make sure to save the token somewhere, since you won’t be able to see it again. Requires scope auth:write.

Parameters:
  • comment (str) – Comment to describe the API token. Tip: Use something to remember where this specific token is used.

  • scopes (list[str]) – List of scopes for the API token.

Returns:

A dictionary containing the API token’s information.

Return type:

dict

create_chart(title: str, chart_type: str, theme: str | None = None, data: DataFrame | str | None = None, external_data_url: str | None = None, folder_id: int | None = None, organization_id: str | None = None, forkable: bool | None = None, language: str | None = None, metadata: dict | None = None) dict[source]

Creates a new Datawrapper chart, table or map.

Deprecated since version Use: the object-oriented chart classes instead (e.g., BarChart, LineChart). This method will be removed in a future version.

Parameters:
  • title (str) – Title for new chart, table or map, by default “New Chart”

  • chart_type (str) – Chart type to be created. See https://developer.datawrapper.de/docs/chart-types

  • theme (str, optional) – Theme to use for new chart, table or map, by default None

  • data (pd.DataFrame | str, optional) – A pandas DataFrame or string containing the data to be added, by default None

  • external_data_url (str, optional) – URL to external data to be added to the chart, table or map,

  • folder_id (int, optional) – ID of folder in Datawrapper.de for the chart, table or map to be created in, by default “”

  • organization_id (str, optional) – ID of the team where the chart should be created. The authenticated user must have access to this team.

  • forkable (bool, optional) – Whether the chart should be forkable or not, by default None

  • language (str, optional) – Locale of the chart (i.e. en-US), by default None

  • metadata (dict, optional) – A Python dictionary of properties to add.

Returns:

A dictionary containing the created chart’s information.

Return type:

dict

create_folder(name: str, parent_id: int | None = None, team_id: int | None = None) dict[source]

Create a new folder.

Parameters:
  • name (str) – Name of the folder to be created.

  • parent_id (int, optional) – The parent folder that the folder belongs to.

  • team_id (int, optional) – The team that the folder belongs to. If teamId is empty, the folder will belong to the user directly.

Returns:

A dictionary containing the folder’s information.

Return type:

dict

create_login_token() dict[source]

Creates a new login token to authenticate a user, for use in CMS integrations.

Login tokens are valid for five minutes and can only be used once.

Returns:

A dictionary containing the login token’s information.

Return type:

dict

create_workspace(name: str, slug: str | None = None) dict[source]

Create a new workspace.

Parameters:
  • name (str) – Name of the workspace to be created (2-100 characters).

  • slug (str, optional) – Slug for the workspace (2-100 characters). If not provided, will be auto-generated from the name.

Returns:

A dictionary containing the workspace’s information.

Return type:

dict

create_workspace_team(workspace_slug: str, name: str, is_private: bool = False, icon: str | None = None) dict[source]

Create a new team in a workspace.

Parameters:
  • workspace_slug (str) – Slug of workspace to create team in.

  • name (str) – Name of the team to be created.

  • is_private (bool, optional) – Whether the team should be private, by default False.

  • icon (str, optional) – Icon for the team (one of 183 available icons).

Returns:

A dictionary containing the team’s information.

Return type:

dict

delete(url: str, timeout: int = 15, data: dict | None = None, extra_headers: dict | None = None) bool[source]

Make a DELETE request to the Datawrapper API.

Parameters:
  • url (str) – The URL to request.

  • timeout (int, optional) – The timeout for the request in seconds, by default 15

  • data (dict, optional) – A dictionary of data to pass to the request, by default None

  • extra_headers (dict, optional) – A dictionary of extra headers to pass to the request, by default None

Returns:

Whether the request was successful.

Return type:

bool

delete_api_token(token_id: str | int) bool[source]

Deletes an API token.

Parameters:

token_id (str | int) – ID of API token to delete.

Returns:

True if the API token was deleted successfully.

Return type:

bool

delete_chart(chart_id: str) bool[source]

Deletes a chart, table or map.

Deprecated since version Use: the object-oriented chart classes instead (e.g., BarChart, LineChart). This method will be removed in a future version.

Parameters:

chart_id (str) – ID of chart, table or map.

Returns:

True if the chart was deleted successfully.

Return type:

bool

delete_folder(folder_id: int) bool[source]

Delete an existing folder.

Parameters:

folder_id (int) – ID of folder to delete.

Returns:

True if the folder was deleted successfully.

Return type:

bool

delete_login_token(token_id: str | int) bool[source]

Deletes a login token.

Parameters:

token_id (str | int) – ID of login token to delete.

Returns:

True if the login token was deleted successfully.

Return type:

bool

delete_workspace(workspace_slug: str) bool[source]

Delete an existing workspace.

Parameters:

workspace_slug (str) – Slug of workspace to delete.

Returns:

True if the workspace was deleted successfully.

Return type:

bool

delete_workspace_team(workspace_slug: str, team_id: str, migration_team_id: str | None = None) bool[source]

Delete a team within a workspace.

Parameters:
  • workspace_slug (str) – Slug of workspace the team belongs to.

  • team_id (str) – ID of team to delete.

  • migration_team_id (str, optional) – Target team ID for migrating team content. If not provided, content will be migrated to the user’s archive.

Returns:

True if the team was deleted successfully.

Return type:

bool

display_chart(chart_id: str) IFrame[source]

Displays a datawrapper chart.

Parameters:

chart_id (str) – ID of chart, table, or map.

Returns:

IFrame displaying the chart.

Return type:

IPython.display.IFrame

export_chart(chart_id: str, unit: str = 'px', mode: str = 'rgb', width: int = 400, height: int | str | None = None, plain: bool = False, zoom: int = 2, scale: int = 1, border_width: int = 20, border_color: str | None = None, transparent: bool = False, download: bool = False, full_vector: bool = False, ligatures: bool = True, logo: str = 'auto', logo_id: str | None = None, dark: bool = False, output: str = 'png', filepath: str = './image.png', display: bool = False) Path | Image[source]

Exports a chart, table, or map.

Deprecated since version Use: the object-oriented chart classes instead (e.g., BarChart, LineChart). This method will be removed in a future version.

Parameters:
  • chart_id (str) – ID of chart, table, or map.

  • unit (str, optional) – One of px, mm, inch. Defines the unit in which the borderwidth, height, and width will be measured in, by default “px”

  • mode (str, optional) – One of rgb or cmyk. Which color mode the output should be in, by default “rgb”

  • width (int, optional) – Width of visualization. If not specified, it takes the chart width, by default 400

  • height (int | str, optional) – Height of visualization. Can be a number or “auto”, by default None

  • plain (bool, optional) –

    Defines if only the visualization should be exported (True), or if it should

    include header and footer as well (False), by default False

  • zoom (int, optional) – Defines the multiplier for the png size, by default 2

  • scale (int, optional) – Defines the multiplier for the pdf size, by default 1

  • border_width (int, optional) – Margin around the visualization, by default 20

  • border_color (str, optional) – Color of the border around the visualization, by default None

  • transparent (bool, optional) – Set to True to export your visualization with a transparent background, by default False

  • download (bool, optional) – Whether to trigger a download, by default False

  • full_vector (bool, optional) – Export as full vector graphic (for supported formats), by default False

  • ligatures (bool, optional) – Enable typographic ligatures, by default True

  • logo (str, optional) – Logo display setting. One of “auto”, “on”, or “off”, by default “auto”

  • logo_id (str, optional) – Custom logo ID to use, by default None

  • dark (bool, optional) – Export in dark mode, by default False

  • output (str, optional) – One of png, pdf, or svg, by default “png”

  • filepath (str, optional) – Name/filepath to save output in, by default “./image.png”

  • display (bool, optional) – Whether to display the exported image as output in the notebook cell, by default False

Returns:

The file path to the exported image or an Image object displaying the image.

Return type:

Path | Image

fork_chart(chart_id: str) dict[source]

Fork a chart, table, or map and create an editable copy.

Deprecated since version Use: the object-oriented chart classes instead (e.g., BarChart, LineChart). This method will be removed in a future version.

Parameters:

chart_id (str) – ID of chart, table, or map.

Returns:

A dictionary containing the information of the chart, table, or map.

Return type:

dict

get(url: str, params: dict | None = None, timeout: int = 15) Any[source]

Make a GET request to the Datawrapper API.

Parameters:
  • url (str) – The URL to request.

  • params (dict, optional) – A dictionary of parameters to pass to the request, by default None

  • timeout (int, optional) – The timeout for the request in seconds, by default 15

Returns:

An object containing the response from the API.

Return type:

Any

get_api_tokens(limit: int = 100, offset: int = 0) dict[source]

Retrieves all API tokens associated to the current user.

Response will not include full tokens for security reasons. Requires scope auth:read.

Parameters:
  • limit (int, optional) – Maximum items to fetch, by default 100. Useful for pagination.

  • offset (int, optional) – Offset for pagination, by default 0.

Returns:

A dictionary containing the API tokens for your Datawrapper account.

Return type:

dict

get_basemap(basemap_id: str, wgs84: bool = False) dict[source]

Get the metadata of the requested basemap.

Parameters:
  • basemap_id (str) – ID of basemap to get.

  • wgs84 (bool, optional) – Whether to return the basemap in the WGS84 project, by default False

Returns:

A dictionary containing the requested basemap’s metadata.

Return type:

dict

get_basemap_key(basemap_id: str, basemap_key: str) dict[source]

Get the list of available values for a basemap’s key.

Parameters:
  • basemap_id (str) – ID of basemap to get.

  • basemap_key (str) – Metadata key of basemap to get.

Returns:

A dictionary containing the requested data.

Return type:

dict

get_basemaps() list[dict][source]

Get a list of the available basemaps.

Returns:

A list of dictionaries containing the basemaps available in your Datawrapper account.

Return type:

list[dict]

get_chart(chart_id: str) dict[source]

Retrieve information of a specific chart, table or map.

Deprecated since version Use: the chart factory function instead to get typed chart instances. This method will be removed in a future version.

Parameters:

chart_id (str) – ID of chart, table, or map.

Returns:

A dictionary containing the information of the chart, table, or map.

Return type:

dict

get_chart_display_urls(chart_id: str) list[dict][source]

Get the URLs for the published chart, table or map.

Parameters:

chart_id (str) – ID of chart, table, or map.

Returns:

A list of dictionaries containing the URLs for the published chart, table, or map.

Return type:

list[dict]

get_charts(user_id: str = '', published: bool = True, search: str = '', order: str = 'DESC', order_by: str = 'createdAt', limit: int = 25, folder_id: int | None = None, team_id: str = '') None | list[Any][source]

Retrieves a list of charts by User

Parameters:
  • user_id (str, optional) – ID of the user to fetch charts for, by default “”

  • published (bool, optional) – Flag to filter resutls by publish status, by default True

  • search (str, optional) – Search for charts with a specific title, by default “”

  • order (str, optional) – Result order (ascending or descending), by default “DESC”

  • order_by (str, optional) – Attribute to order by. One of createdAt, email, id, or name, by default “createdAt”

  • limit (int, optional) – Maximum items to fetch, by default 25

  • folder_id (int, optional) – ID of folder in Datawrapper.de where to list charts, by default “”

  • team_id (str, optional) – ID of the team where to list charts. The authenticated user must have access to this team, by default “”

Returns:

List of charts.

Return type:

list

get_data(chart_id: str)[source]

Retrieve the data stored for a specific chart, table or map, which is typically CSV.

Parameters:

chart_id (str) – ID of chart, table, or map.

Returns:

A dictionary containing the information of the chart, table, or map.

Return type:

dict

get_folder(folder_id: int) dict[source]

Get an existing folder.

Parameters:

folder_id (int) – ID of folder to get.

Returns:

A dictionary containing the folder’s information.

Return type:

dict

get_folders() dict[source]

Get a list of folders in your Datawrapper account.

Returns:

A dictionary containing the folders in your Datawrapper account and their information.

Return type:

dict

get_iframe_code(chart_id: str, responsive: bool = False) str[source]

Returns a chart, table, or map’s iframe embed code.

Parameters:
  • chart_id (str) – ID of chart, table, or map.

  • responsive (bool, optional) – Whether to return a responsive iframe embed code., by default False

Returns:

iframe embed code.

Return type:

str

get_login_tokens(limit: int = 100, offset: int = 0) dict[source]

Retrieves all login tokens associated to the current user.

Parameters:
  • limit (int, optional) – Maximum items to fetch, by default 100. Useful for pagination.

  • offset (int, optional) – Offset for pagination, by default 0.

Returns:

A dictionary containing the login tokens for your Datawrapper account.

Return type:

dict

get_my_account() dict[source]

Access your account information.

Returns:

A dictionary containing your account information.

Return type:

dict

get_my_recently_edited_charts(limit: int = 100, offset: int = 0, min_last_edit_step: str | int = 0) dict[source]

Get a list of your recently edited charts.

Parameters:
  • limit (int) – Maximum items to fetch. Useful for pagination. 100 by default.

  • offset (int) – Number of items to skip. Useful for pagination. Zero by default.

  • min_last_edit_step (int) – Filter visualizations by the last editor step they’ve been opened in (1=upload, 2=describe, 3=visualize, etc). Zero by default.

Returns:

A dictionary with the list of charts and metadata about the selection.

Return type:

dict

get_my_recently_published_charts(limit: int = 100, offset: int = 0, min_last_edit_step: int = 0) dict[source]

Get a list of your recently published charts.

Parameters:
  • limit (int) – Maximum items to fetch. Useful for pagination. 100 by default.

  • offset (int) – Number of items to skip. Useful for pagination. Zero by default.

  • min_last_edit_step (int) – Filter visualizations by the last editor step they’ve been opened in (1=upload, 2=describe, 3=visualize, etc). Zero by default.

Returns:

A dictionary with the list of charts and metadata about the selection.

Return type:

dict

get_oembed(url: str, max_width: int | None = None, max_height: int | None = None, iframe: bool | None = None) dict[source]

Get an oEmbed object for a chart, table, or map.

Parameters:
  • url (str) – URL of chart, table, or map.

  • max_width (int, optional) – Maximum width of the oEmbed object, by default None

  • max_height (int, optional) – Maximum height of the oEmbed object, by default None

  • iframe (bool, optional) – Whether to return an iframe embed code, by default None, which will return a responsive embed.

Returns:

A dictionary containing the oEmbed object.

Return type:

dict

get_recently_edited_charts(user_id: int | str, limit: int = 100, offset: int = 0, min_last_edit_step: str | int = 0) dict[source]

Get a list of your recently edited charts.

Parameters:
  • user_id (int | str) – ID of user to get recently edited charts for.

  • limit (str | int) – Maximum items to fetch. Useful for pagination. 100 by default.

  • offset (str | int) – Number of items to skip. Useful for pagination. Zero by default.

  • min_last_edit_step (str | int) – Filter visualizations by the last editor step they’ve been opened in (1=upload, 2=describe, 3=visualize, etc). Zero by default.

Returns:

A dictionary with the list of charts and metadata about the selection.

Return type:

dict

get_recently_published_charts(user_id: int | str, limit: int = 100, offset: int = 0, min_last_edit_step: str | int = 0) dict[source]

Get a list of your recently published charts.

Parameters:
  • user_id (int | str) – ID of user to get recently published charts for.

  • limit (int) – Maximum items to fetch. Useful for pagination. 100 by default.

  • offset (int) – Number of items to skip. Useful for pagination. Zero by default.

  • min_last_edit_step (str | int) – Filter visualizations by the last editor step they’ve been opened in (1=upload, 2=describe, 3=visualize, etc). Zero by default.

Returns:

A dictionary with the list of charts and metadata about the selection.

Return type:

dict

get_river(approved: bool | None = None, limit: int = 100, offset: int = 0, search: str | None = None) dict[source]

Search and filter a list of your River charts.

Parameters:
  • approved (bool, optional) – Filter by approved status, by default None

  • limit (int) – Maximum items to fetch, by default 100

  • offset (int) – Offset for pagination, by default 0

  • search (str, optional) – Search for charts with a specific title, by default None

Returns:

A dictionary containing the River charts.

Return type:

dict

get_river_chart(chart_id: str) dict[source]

Get a River chart by ID.

Parameters:

chart_id (str) – ID of River chart to get.

Returns:

A dictionary containing the River chart.

Return type:

dict

get_themes(limit: int = 100, offset: int = 0, deleted: bool = False) dict[source]

Get a list of themes in your Datawrapper account.

Parameters:
  • limit (int) – Maximum items to fetch. Useful for pagination. Default 100.

  • offset (int) – Number of items to skip. Useful for pagination. Default zero.

  • deleted (bool) – Whether to include deleted themes

Returns:

A dictionary containing the themes in your Datawrapper account.

Return type:

dict

get_token_scopes() list[str][source]

Get the scopes that are available to the current user.

Returns:

A list containing the scopes available to the current user.

Return type:

list[str]

get_user(user_id: str) dict[source]

Get an existing user.

Parameters:

user_id (str) – ID of user to get.

Returns:

A dictionary containing the user’s information.

Return type:

dict

get_users(team_id: str | None = None, search: str | None = None, order: str = 'ASC', order_by: str = 'id', limit: int = 100, offset: int = 0) dict[source]

Get a list of users in your Datawrapper account.

Parameters:
  • team_id (str, optional) – ID of team to get users for, by default None

  • search (str, optional) – Search for users with a specific name, by default None

  • order (str, optional) – Result order (ascending or descending), by default “ASC.” Supply “DESC” for descending order.

  • order_by (str, optional) – Attribute to order by. By default “id”

  • limit (int, optional) – Maximum items to fetch, by default 100. Useful for pagination.

  • offset (int, optional) – Offset for pagination, by default 0.

Returns:

A dictionary containing the users in your Datawrapper account.

Return type:

dict

get_workspace(workspace_slug: str) dict[source]

Get an existing workspace by its slug.

Parameters:

workspace_slug (str) – Slug of workspace to get.

Returns:

A dictionary containing the workspace’s information.

Return type:

dict

get_workspace_members(workspace_slug: str, search: str | None = None, order: str = 'ASC', order_by: str = 'name', limit: int = 100, offset: int = 0, role: str | None = None, include_invites: bool = False) dict[source]

Get a list of members in a workspace.

Parameters:
  • workspace_slug (str) – Slug of workspace to get members for.

  • search (str, optional) – Search for a user email or name including this term.

  • order (str, optional) – Result order (ascending or descending), by default “ASC.”

  • order_by (str, optional) – Attribute to order by. One of “name”, “visCount”, “lastSeen”, or “role”. By default “name”

  • limit (int, optional) – Maximum items to fetch, by default 100. Useful for pagination.

  • offset (int, optional) – Number of items to skip, by default 0. Useful for pagination.

  • role (str, optional) – Filter by workspace role. One of “member”, “manager”, or “admin”.

  • include_invites (bool, optional) – Include pending invites, by default False.

Returns:

A dictionary containing the members in the workspace.

Return type:

dict

get_workspace_team(workspace_slug: str, team_id: str) dict[source]

Get a team within a workspace.

Parameters:
  • workspace_slug (str) – Slug of workspace the team belongs to.

  • team_id (str) – ID of team to get.

Returns:

A dictionary containing the team’s information.

Return type:

dict

get_workspace_team_members(workspace_slug: str, team_id: str, search: str | None = None, order: str = 'ASC', order_by: str = 'name', limit: int = 100, offset: int = 0, role: str | None = None, include_invites: bool = False) dict[source]

Get a list of members in a workspace team.

Parameters:
  • workspace_slug (str) – Slug of workspace the team belongs to.

  • team_id (str) – ID of team to get members for.

  • search (str, optional) – Search for a user email or name including this term.

  • order (str, optional) – Result order (ascending or descending), by default “ASC.”

  • order_by (str, optional) – Attribute to order by. One of “name”, “visCount”, “lastSeen”, “workspaceRole”, or “role”. By default “name”

  • limit (int, optional) – Maximum items to fetch, by default 100. Useful for pagination.

  • offset (int, optional) – Number of items to skip, by default 0. Useful for pagination.

  • role (str, optional) – Filter by team role. One of “manager” or “member”.

  • include_invites (bool, optional) – Include pending invites for this team, by default False.

Returns:

A dictionary containing the members in the workspace team.

Return type:

dict

get_workspace_teams(workspace_slug: str, search: str | None = None, order: str = 'ASC', order_by: str = 'name', limit: int = 100, offset: int = 0) dict[source]

Get a list of teams in a workspace.

Parameters:
  • workspace_slug (str) – Slug of workspace to get teams for.

  • search (str, optional) – Search for a team name or id including this term.

  • order (str, optional) – Result order (ascending or descending), by default “ASC.”

  • order_by (str, optional) – Attribute to order by. One of “name” or “createdAt”. By default “name”

  • limit (int, optional) – Maximum items to fetch, by default 100. Useful for pagination.

  • offset (int, optional) – Number of items to skip, by default 0. Useful for pagination.

Returns:

A dictionary containing the teams in the workspace.

Return type:

dict

get_workspaces(search: str | None = None, order: str = 'ASC', order_by: str = 'name', limit: int = 100, offset: int = 0) dict[source]

Get a list of workspaces in your Datawrapper account.

Parameters:
  • search (str, optional) – Search for a workspace name or slug including this term, by default None

  • order (str, optional) – Result order (ascending or descending), by default “ASC.” Supply “DESC” for descending order.

  • order_by (str, optional) – Attribute to order by. One of “name”, “slug”, or “created_at”. By default “name”

  • limit (int, optional) – Maximum items to fetch, by default 100. Useful for pagination.

  • offset (int, optional) – Number of items to skip, by default 0. Useful for pagination.

Returns:

A dictionary containing the workspaces in your Datawrapper account.

Return type:

dict

login(token: str) str[source]

Login using a one-time login token and redirect to the URL associated with the token.

For use in CMS integrations.

Parameters:

token (str) – Login token.

Returns:

The HTML of the page that the token redirects to.

Return type:

str

move_chart(chart_id: str, folder_id: int) dict[source]

Moves a chart, table, or map to a specified folder.

Parameters:
  • chart_id (str) – ID of chart, table, or map.

  • folder_id (int) – ID of folder to move visualization to.

patch(url: str, data: dict | None = None, timeout: int = 15, extra_headers: dict | None = None) dict[source]

Make a PATCH request to the Datawrapper API.

Parameters:
  • url (str) – The URL to request.

  • data (dict) – A dictionary of data to pass to the request, by default None

  • timeout (int, optional) – The timeout for the request in seconds, by default 15

  • extra_headers (dict, optional) – A dictionary of extra headers to pass to the request, by default None

Returns:

A dictionary containing the response from the API.

Return type:

dict

post(url: str, data: dict | None = None, timeout: int = 30, extra_headers: dict | None = None) dict | bool[source]

Make a POST request to the Datawrapper API.

Parameters:
  • url (str) – The URL to request.

  • data (dict) – A dictionary of data to pass to the request, by default None

  • timeout (int, optional) – The timeout for the request in seconds, by default 15

  • extra_headers (dict, optional) – A dictionary of extra headers to pass to the request, by default None

Returns:

A dictionary containing the response from the API or True if the request was successful but did not return any data.

Return type:

dict | bool

publish_chart(chart_id: str, display: bool = False) dict | IFrame[source]

Publishes a chart, table or map.

Deprecated since version Use: the object-oriented chart classes instead (e.g., BarChart, LineChart). This method will be removed in a future version.

Parameters:
  • chart_id (str) – ID of chart, table or map.

  • display (bool, optional) – Display the published chart as output in notebook cell, by default False

Returns:

Either a dictionary containing the published chart’s information or an IFrame object displaying the chart.

Return type:

dict | IFrame

put(url: str, data: dict | bytes | None = None, timeout: int = 15, extra_headers: dict | None = None, dump_data: bool = True) bool[source]

Make a PUT request to the Datawrapper API.

Parameters:
  • url (str) – The URL to request.

  • data (dict | bytes) – A dictionary of data to pass to the request, or raw bytes when dump_data is False, by default None

  • timeout (int, optional) – The timeout for the request in seconds, by default 15

  • extra_headers (dict, optional) – A dictionary of extra headers to pass to the request, by default None

  • dump_data (bool, optional) – Whether to dump the data to json, by default True

Returns:

Whether the request was successful.

Return type:

bool

refresh_data(chart_id: str) dict[source]

Fetch configured external data and add it to the chart.

Parameters:

chart_id (str) – ID of chart, table or map to add data to.

Returns:

A dictionary containing the chart’s information.

Return type:

dict

remove_workspace_members(workspace_slug: str, member_ids: list[int]) bool[source]

Remove members from a workspace.

Parameters:
  • workspace_slug (str) – Slug of workspace to remove members from.

  • member_ids (list[int]) – Array of member user IDs to remove.

Returns:

True if the members were removed successfully.

Return type:

bool

remove_workspace_team_members(workspace_slug: str, team_id: str, member_ids: list[int]) bool[source]

Remove multiple users from a workspace team.

Parameters:
  • workspace_slug (str) – Slug of workspace the team belongs to.

  • team_id (str) – ID of team to remove users from.

  • member_ids (list[int]) – IDs of the users to remove from the team.

Returns:

True if the members were removed successfully.

Return type:

bool

update_api_token(id: str | int, comment: str, scopes: list[str] | None = None) bool[source]

Updates an existing API token.

Parameters:
  • id (str | int) – ID of API token to update.

  • comment (str) – Comment to describe the API token. Tip: Use something to remember where this specific token is used.

  • scopes (list[str], optional) – List of scopes for the API token.

Returns:

True if the API token was updated successfully.

Return type:

bool

update_chart(chart_id: str, title: str | None = None, chart_type: str | None = None, theme: str | None = None, data: DataFrame | str | None = None, external_data_url: str | None = None, folder_id: int | None = None, organization_id: str | None = None, forkable: bool | None = None, language: str | None = None, metadata: dict | None = None) dict[source]

Updates a chart’s title, theme, type, language, folder or organization.

Deprecated since version Use: the object-oriented chart classes instead (e.g., BarChart, LineChart). This method will be removed in a future version.

Parameters:
  • chart_id (str) – ID Of chart, table, or map.

  • title (str, optional) – New title

  • chart_type (str, optional) – New chart type. See https://developer.datawrapper.de/docs/chart-types

  • theme (str, optional) – New theme

  • data (pd.DataFrame | str, optional) – A pandas DataFrame or string containing the data to be added, by default None

  • external_data_url (str, optional) – URL to external data to be added to the chart, table or map,

  • folder_id (int, optional) – New folder’s ID

  • organization_id (str, optional) – New organization’s ID

  • forkable (bool, optional) – Whether the chart should be forkable or not, by default None

  • language (str, optional) – New language

  • metadata (dict, optional) – A Python dictionary of properties to add.

Returns:

A dictionary containing the updated chart’s information.

Return type:

dict

Raises:

InvalidRequestError – If no updates are submitted.

update_description(chart_id: str, source_name: str | None = None, source_url: str | None = None, intro: str | None = None, byline: str | None = None, aria_description: str | None = None, number_prepend: str | None = None, number_append: str | None = None, number_format: str | None = None, number_divisor: int | None = None, hide_title: bool = False) dict[source]

Update a chart’s description attributes

A convienece method for updating the ‘describe’ key of a chart’s metadata.

Parameters:
  • chart_id (str) – ID of chart, table or map.

  • source_name (str, optional) – Source of data

  • source_url (str, optional) – URL of source of data

  • intro (str, optional) – Introduction of your chart, table or map

  • byline (str, optional) – Who made this?

  • aria_description (str, optional) – Alt text description

  • number_prepend (str, optional) – Something to put before the number

  • number_append (str, optional) – Something to after before the number

  • number_format (str, optional) – The format number

  • number_divisor (str, optional) – A multiplier or divisor for the numbers

  • hide_title (bool) – Whether or not to hide the chart title

Returns:

A dictionary containing the updated chart’s information.

Return type:

dict

Raises:

InvalidRequestError – If no updates are submitted.

update_folder(folder_id: str | int, name: str | None = None, parent_id: int | None = None, team_id: int | None = None, user_id: int | None = None) dict[source]

Update an existing folder.

Parameters:
  • folder_id (str | int) – ID of folder to update.

  • name (str, optional) – Name to change the folder to.

  • parent_id (int, optional) – The parent folder where this folder is stored.

  • team_id (int, optional) – The team that the folder belongs to.

  • user_id (int, optional) – The user that the folder belongs to.

Returns:

A dictionary with the folder’s updated metadata

Return type:

dict

update_metadata(chart_id: str, metadata: dict) dict[source]

A deprecated method of the update_chart method.

update_my_account(name: str | None = None, email: str | None = None, role: str | None = None, language: str | None = None, password: str | None = None, old_password: str | None = None) dict[source]

Update your account information.

Parameters:
  • name (str, optional) – Your new name, by default None

  • email (str, optional) – Your new email, by default None

  • role (str, optional) – Your new role, by default None

  • language (str, optional) – Your new language, by default None

  • password (str, optional) – Your new, strong password, by default None

  • old_password (str, optional) – Your previous password, by default None

Returns:

A dictionary containing your updated account information.

Return type:

dict

update_my_settings(active_team: str | None = None) dict[source]

Update your account information.

Parameters:

active_team (str, optional) – Your active team

Returns:

The user settings dictionary following the change.

Return type:

dict

update_river_chart(chart_id: str, description: str, byline: str, tags: list[str], forkable: bool) bool[source]

Update a River chart’s approved status.

Parameters:
  • chart_id (str) – ID of River chart to update.

  • description (str) – Description of the River chart.

  • byline (str) – Byline of the River chart.

  • tags (list[str]) – Tags of the River chart.

  • forkable (bool) – Whether the River chart is forkable.

Returns:

True if the River chart was updated successfully.

Return type:

bool

update_settings(user_id: int | str, active_team: str | None = None) dict[source]

Update your account information.

Parameters:

active_team (str, optional) – Your active team

Returns:

The user settings dictionary following the change.

Return type:

dict

update_user(user_id: str, name: str | None = None, email: str | None = None, role: str | None = None, language: str | None = None, activate_token: str | None = None, password: str | None = None, old_password: str | None = None)[source]

Update an existing user.

Parameters:
  • user_id (str) – ID of user to update.

  • name (str, optional) – Name to change the user to.

  • email (str, optional) – Email to change the user to.

  • role (str, optional) – Role to change the user to. One of owner, admin, or member.

  • language (str, optional) – Language to change the user preference to.

  • activate_token (str, optional) – Activate token, typically used to unset it when activating user.

  • password (str, optional) – Password to change the user to.

  • old_password (str, optional) – Old password to change the user to.

Returns:

A dictionary with the user’s updated metadata

Return type:

dict

update_workspace(workspace_slug: str, name: str | None = None, slug: str | None = None, settings: dict | None = None, secrets: dict | None = None, color: str | None = None) dict[source]

Update an existing workspace.

Parameters:
  • workspace_slug (str) – Slug of workspace to update.

  • name (str, optional) – New name for the workspace.

  • slug (str, optional) – New slug for the workspace.

  • settings (dict, optional) – Settings object for the workspace.

  • secrets (dict, optional) – Secrets object for the workspace.

  • color (str, optional) – Color for the workspace.

Returns:

A dictionary with the workspace’s updated metadata.

Return type:

dict

Raises:

Exception – If no parameters are supplied to update the workspace.

update_workspace_members(workspace_slug: str, member_ids: list[int], role: str) dict[source]

Update workspace members’ roles.

Parameters:
  • workspace_slug (str) – Slug of workspace to update members for.

  • member_ids (list[int]) – Array of member user IDs to update.

  • role (str) – New role to assign to the members. One of “member”, “manager”, or “admin”.

Returns:

True if the workspace members were updated successfully.

Return type:

bool

update_workspace_team(workspace_slug: str, team_id: str, name: str | None = None, is_private: bool | None = None, settings: dict | None = None, secrets: dict | None = None, icon: str | None = None) dict[source]

Update a team within a workspace.

Parameters:
  • workspace_slug (str) – Slug of workspace the team belongs to.

  • team_id (str) – ID of team to update.

  • name (str, optional) – New name for the team.

  • is_private (bool, optional) – Whether the team should be private.

  • settings (dict, optional) – Settings object for the team.

  • secrets (dict, optional) – Secrets object for the team.

  • icon (str, optional) – Icon for the team.

Returns:

A dictionary with the team’s updated metadata.

Return type:

dict

Raises:

Exception – If no parameters are supplied to update the team.

update_workspace_team_members(workspace_slug: str, team_id: str, member_ids: list[int], role: str = 'member') dict[source]

Modify the role of users in a workspace team.

Parameters:
  • workspace_slug (str) – Slug of workspace the team belongs to.

  • team_id (str) – ID of team to update members in.

  • member_ids (list[int]) – IDs of the users to modify in the team.

  • role (str, optional) – Role to assign to the users in the team. One of “manager” or “member”. By default “member”.

Returns:

True if the members were updated successfully.

Return type:

bool