GitHub user dosubot[bot] added a comment to the discussion: Unable to Retrieve the query_context Through API After Chart Creation Without Loading Chart in UI?
<!-- Answer --> There isn't an official API or backend endpoint in Superset 4.1.2 that will programmatically generate or retrieve the `query_context` for a chart without UI interaction. The reason `query_context` is null after API chart creation is that its generation is handled by frontend JavaScript logic when the chart is loaded in the UI, and this isn't triggered by the backend or API alone [[source]](https://github.com/apache/superset/issues/33615). The backend does have a utility (`QueryContextFactory`) that can generate a `query_context` from chart parameters, but this isn't exposed via any standard API route—you'd need to write a custom backend script or extension to use it [[source]](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/common/query_context_factory.py). Workarounds include: manually opening and saving each chart in the UI (impractical for many charts), using browser automation (like Cypress) to trigger the frontend logic in bulk, or writing a custom backend job that uses `QueryContextFactory` to populate `query_context` for your charts [[source]](https://github.com/apache/superset/issues/33615). If you want to fully automate chart creation and data fetching (including `query_context`), you'd need to either precompute and supply the correct `query_context` yourself, or extend Superset with a custom endpoint that exposes this backend logic. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/3ba376c2-f3ce-47bb-9d3e-1226fc79cb8f?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/3ba376c2-f3ce-47bb-9d3e-1226fc79cb8f?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/3ba376c2-f3ce-47bb-9d3e-1226fc79cb8f?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/3ba376c2-f3ce-47bb-9d3e-1226fc79cb8f?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/3ba376c2-f3ce-47bb-9d3e-1226fc79cb8f?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/3ba376c2-f3ce-47bb-9d3e-1226fc79cb8f?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/3ba376c2-f3ce-47bb-9d3e-1226fc79cb8f?feedback_type=other)</sup> [](https://app.dosu.dev/a28d3c7e-a9d3-459e-9fb6-3a6f9ff4f357/ask?utm_source=github)& nbsp;[](https://go.dosu.dev/discord-bot) [](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/apache/superset/discussions/34750) GitHub link: https://github.com/apache/superset/discussions/34750#discussioncomment-14153091 ---- This is an automatically sent email for notifications@superset.apache.org. To unsubscribe, please send an email to: notifications-unsubscr...@superset.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: notifications-unsubscr...@superset.apache.org For additional commands, e-mail: notifications-h...@superset.apache.org