GitHub user dosubot[bot] added a comment to the discussion: Download dashboard 
as an image using API

<!-- Answer -->
Yes, it is possible to download a dashboard as an image using the API in Apache 
Superset.

### Steps to Download a Dashboard as an Image via API

1. **Identify the Dashboard ID and Digest**
   - You need the dashboard's primary key (`pk`) and a unique hex digest 
(`digest`) for the dashboard. The digest is used to identify the specific state 
of the dashboard.

2. **API Endpoint**
   - Use the following endpoint to request the dashboard image:
     ```
     GET /api/v1/dashboard/{pk}/thumbnail/{digest}/
     ```
     Replace `{pk}` with your dashboard's ID and `{digest}` with the 
appropriate digest value.

3. **Expected Responses**
   - **HTTP 200**: Returns the dashboard thumbnail image in binary format 
(image).
   - **HTTP 202**: The thumbnail does not exist in the cache; the server will 
start generating it asynchronously. You may need to retry after a short wait.

   [See API 
details](https://github.com/apache/superset/blob/master/docs/static/resources/openapi.json)

4. **Authentication**
   - Make sure your API request is authenticated (e.g., using a session cookie 
or Bearer token, depending on your Superset setup).

5. **Example Request (using `curl`):**
   ```bash
   curl -X GET \
     -H "Authorization: Bearer <YOUR_ACCESS_TOKEN>" \
     "https://<your-superset-domain>/api/v1/dashboard/<pk>/thumbnail/<digest>/"
   --output dashboard.png
   ```

6. **Handling Asynchronous Generation**
   - If you receive a 202 response, wait a few seconds and retry the request 
until you receive the image (HTTP 200).

### Notes

- The thumbnail image represents the dashboard's current state as rendered in 
the UI.
- The digest parameter ensures you get the correct version of the dashboard. If 
you are unsure how to obtain the digest, you may need to inspect the Superset 
frontend or API responses for this value.

For more details on how this is implemented in the frontend, you can refer to 
the [useDownloadScreenshot 
hook](https://github.com/apache/superset/blob/master/superset-frontend/src/dashboard/hooks/useDownloadScreenshot.ts),
 which uses a similar API endpoint to fetch and download dashboard screenshots 
as images or PDFs.

Let me know if you need more details on obtaining the digest or automating this 
process!


<!-- Dosu Comment Footer -->
*To reply, just mention my name [@dosu](https://go.dosu.dev/dosubot).*

---
<sup>How did I do? 
[Good](https://app.dosu.dev/response-feedback/ec253eb5-d022-4cd1-9427-6753be50215b?feedback_type=great_response)
 | 
[Irrelevant](https://app.dosu.dev/response-feedback/ec253eb5-d022-4cd1-9427-6753be50215b?feedback_type=irrelevant_answer)
 | 
[Incorrect](https://app.dosu.dev/response-feedback/ec253eb5-d022-4cd1-9427-6753be50215b?feedback_type=incorrect_sources)
 | 
[Verbose](https://app.dosu.dev/response-feedback/ec253eb5-d022-4cd1-9427-6753be50215b?feedback_type=too_verbose)
 | 
[Hallucination](https://app.dosu.dev/response-feedback/ec253eb5-d022-4cd1-9427-6753be50215b?feedback_type=hallucination)
 | [Report 
🐛](https://app.dosu.dev/response-feedback/ec253eb5-d022-4cd1-9427-6753be50215b?feedback_type=bug_report)
 | 
[Other](https://app.dosu.dev/response-feedback/ec253eb5-d022-4cd1-9427-6753be50215b?feedback_type=other)</sup>&nbsp;&nbsp;[![Join
 
Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Sh
 are on 
X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/33589)

GitHub link: 
https://github.com/apache/superset/discussions/33589#discussioncomment-13282587

----
This is an automatically sent email for [email protected].
To unsubscribe, please send an email to: 
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to