This guide explains how to generate tokens to securely embed reports from our platform into your applications or web pages using an iframe.
To embed a specific report, generate a short-lived token using your personal API token.
You’ll need:
API Endpoint:
POST /api/reports/{report_id}/generate-token
curl -X POST "https://pyqueryhub.com/api/reports/REPORT_ID_HERE/generate-token" \
-H "Authorization: Bearer YOUR_PERSONAL_API_TOKEN" \
-H "Accept: application/json"
Explanation:
-X POST
: Makes a POST request.Authorization
: Uses your Personal API Token.Accept
: Specifies you want JSON.{
"message": "Report access token generated successfully.",
"token": "shortLivedRandomStringTokenValueGeneratedByTheApi",
"report_id": "REPORT_ID_HERE",
"expires_at": "2025-05-20T19:15:00.000000Z",
"view_url": "https://pyqueryhub.com/api/reports/{REPORT_ID_HERE}/view/{shortLivedRandomStringTokenValueGeneratedByTheApi}"
}
src
.If the request fails (e.g., invalid token or no permission), the API returns a 4xx error with a JSON explanation.
{danger} Only call this on your back-end. Keep the API Token secret
view_url
in an IframeEmbed the report using the view_url
:
<iframe src="PASTE_THE_VIEW_URL_HERE"
width="100%"
height="600px"
frameborder="0"
title="Embedded Report">
</iframe>
<iframe src="https://pyqueryhub.com/api/reports/REPORT_ID_HERE/view/shortLivedRandomStringTokenValueGeneratedByTheApi"
width="100%"
height="600px"
frameborder="0"
title="Embedded Report Name">
</iframe>
⚠️ The
view_url
expires after 5 minutes. If a user refreshes or revisits the page later, generate a new token programmatically.
If you encounter issues, inspect the API response or contact support.