Publishing a visualization

Hitting Publish on a Datawrapper visualization means that it becomes, well, public. (It also implies that it's (close to being) finished, which is reason to celebrate.) Here's how to publish with the API.

Before you publish a visualization, it can be a good idea to check its publish status. Has it already been published, maybe? If yes, when and how many times?

To do so, perform a GET request on your chart. Make sure to replace the <ID> with your chart ID (a 5-character ID like "384dj") and the <YOUR_TOKEN_HERE> with your API access token:

curl --request GET \
  --url https://api.datawrapper.de/v3/charts/<ID> \
  --header 'Authorization: Bearer <YOUR_TOKEN_HERE>'

Below is an abridged response to a GET request made on a chart that has not yet been published.

{
  "id": "aBcDe",
  "lastEditStep": 2,
  "publishedAt": null,
  "publicUrl": null,
  "publicVersion": 0,
  "metadata": {
    "publish": {
      "embed-width": 536,
      "embed-height": 674
    },
    ...
  },
  "url": "/v3/charts/aBcDe",
  ...
}

You can tell this chart is still unpublished by the values of four properties:

Name

Value when unpublished

lastEditStep

1 - 4

publishedAt

null

publicUrl

null

publicVersion

0

To publish (and republish) a chart, make the following POST request:

curl --request POST \
  --url https://api.datawrapper.de/v3/charts/<ID>/publish \
  --header 'Authorization: Bearer <YOUR_TOKEN_HERE>'

This can take a few seconds. You can check the progress with the following GET request. It returns a list of steps that have completed for the chart to get published:

curl --request GET \
  --url https://api.datawrapper.de/v3/charts/<ID>/publish/status/<VERSION> \
  --header 'Authorization: Bearer <YOUR_TOKEN_HERE>'

Your POST request will return the data for your chart, including its newly generated embed codes and public URL. You can check if your chart is published by opening the URL https://www.datawrapper.de/_/<ID>, like so: https://www.datawrapper.de/_/HpeMi

{
    "version": 1,
    "url": "//datawrapper.dwcdn.net/aBcDe/1/",
    "data": {
        "metadata": {
            "publish": {
                "embed-width": 500,
                "embed-height": 600,
                "embed-codes": {
                    "embed-method-iframe": "<iframe src= ..... ></iframe>",
                    "embed-method-responsive": "<iframe id= .... ></iframe <script type= ....></script>"
                }
            },
	          ...
        },      
      	"lastEditStep": 5,
        "publishedAt": "2018-01-21 09:14:12",
        ...
            }
        }
    }
}

Name

Type

Description

embed‑width

Number

The width of the embedded chart. This will already be defined and present in the chart data even before publishing.

embed‑height

Number

The height of the embedded chart. This will already be defined and present in the chart data even before publishing.

embed‑codes

String

This section is only present if the chart is published. It contains the two embed codes described below.

embed‑method‑iframe

String

This is the embed code for a non-responsive iframe. It consists of just an iframe. Do not change any parts of this embed code.

embed‑method‑responsive

String

This is the embed code for a responsive iframe. It consists of an iframe and a script. Do not change any parts of this embed code.

lastEditStep

Number

This defines what stage your chart is in. Stages 1-4 are pre-publishing.\
1: Upload\2: Describe\3: Visualize\4: Publish page accessed5: Chart Published\

publishedAt

Date\ YYYY‑MM‑DD

This is the date and time that the chart was last published.

And that's it! You've successfully published a visualization.