You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "satanic-panic (via GitHub)" <gi...@apache.org> on 2025/08/13 09:37:05 UTC
[D] Filtered Chart Data via API [superset]
GitHub user satanic-panic created a discussion: Filtered Chart Data via API
Hi, I'm a beginner to Apache Superset and I've been exploring the API.
Specifically there's a use case I would like to employ but so far have not found a way to do it. Essentially I want to fetch chart data in a format like JSON, similar to the /api/v1/chart/data call, but be able to filter those results in the request itself. So if the chart has a column named ID, per example, I want to be able to apply a filter such as "ID == [value]" or "WHERE ID LIKE [value]".
Is this at all possible? If so how? I have played around with Jinja Templating and Dashboard filters but haven't found a way to make them interact with the API call. I have also looked into Preset but that currently isn't an option so I was looking for alternatives that do not employ third party tools.
In case it's relevant, I'm running Apache Superset on a Docker Compose container within an Ubuntu VM.
Thank you in advance for any forthcoming replies.
GitHub link: https://github.com/apache/superset/discussions/34668
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Filtered Chart Data via API [superset]
Posted by "satanic-panic (via GitHub)" <gi...@apache.org>.
GitHub user satanic-panic added a comment to the discussion: Filtered Chart Data via API
Answering my own question because I found the solution. Dosu didn't solve my issue but pointed me in the right direction. For future reference of anyone trying to do this like me and not finding any resources online (like I didn't) the request is as follows:
POST /api/v1/chart/data
Example payload:
{
"datasource": {
"id": 123,
"type": "table"
},
"queries": [
{
"columns": ["col1", "col2"],
"filters": [
{ "col": "col1", "op": "==", "val": 123 }
],
"metrics": [],
"row_limit": 1000
}
],
"result_format": "json",
"result_type": "full"
}
GitHub link: https://github.com/apache/superset/discussions/34668#discussioncomment-14091439
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Filtered Chart Data via API [superset]
Posted by "satanic-panic (via GitHub)" <gi...@apache.org>.
GitHub user satanic-panic added a comment to the discussion: Filtered Chart Data via API
Thank you for the prompt reply. I have seen this before and have tried it, in fact I just tried it again to make sure I wasn't crazy, but unfortunately it simply does not work, hence the reason for my question. My Apache Superset version is 4.1.3 if that's at all relevant.
GitHub link: https://github.com/apache/superset/discussions/34668#discussioncomment-14091272
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Filtered Chart Data via API [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Filtered Chart Data via API
<!-- Greeting -->
Hi @satanic-panic! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.
<!-- Answer -->
Yes, you can filter chart data directly via the `/api/v1/chart/data` API endpoint by sending a POST request with a JSON payload. In your payload, include a `filters` array inside the `queries` list, where each filter specifies the column (`col`), operator (`op`), and value (`val`). Supported operators include `==`, `LIKE`, `ILIKE`, `IN`, and more.
Here's a minimal example for filtering by equality and LIKE:
```json
{
"datasource": "your_table_or_dataset_id__table",
"queries": [
{
"filters": [
{ "col": "ID", "op": "==", "val": 123 },
{ "col": "NAME", "op": "LIKE", "val": "%foo%" }
]
}
]
}
```
Replace `"your_table_or_dataset_id__table"` with your actual datasource identifier. The `filters` array can include as many filter objects as you need, using any supported operator.
Jinja templating and dashboard filters do not interact directly with this API call. Jinja is only relevant if you use it in the `where` or `having` clauses in the `extras` field of your query object, but for most use cases, specifying filters as shown above is the most straightforward approach for API-based filtering.
For more details, see the [relevant code and schema](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py) and [discussion on API usage](https://github.com/apache/superset/discussions/32117#discussioncomment-12041271).
<!-- 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/e4347900-eed7-4dda-bc7d-de563b3a3983?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/e4347900-eed7-4dda-bc7d-de563b3a3983?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/e4347900-eed7-4dda-bc7d-de563b3a3983?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/e4347900-eed7-4dda-bc7d-de563b3a3983?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/e4347900-eed7-4dda-bc7d-de563b3a3983?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/e4347900-eed7-4dda-bc7d-de563b3a3983?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/e4347900-eed7-4dda-bc7d-de563b3a3983?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/34668)
GitHub link: https://github.com/apache/superset/discussions/34668#discussioncomment-14091144
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Filtered Chart Data via API [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] added a comment to the discussion: Filtered Chart Data via API
<!-- Answer -->
Filtering via the `/api/v1/chart/data` endpoint is fully supported in Superset 4.1.3, and the payload should include a `filters` array inside each query object, with each filter specifying `col`, `op`, and `val` keys. If filtering isn't working, common causes are typos in column names, unsupported operators, datatype mismatches, or database driver limitations. The API will return a validation error if the payload is malformed, or sometimes a `rejected_filters` section in the response if a filter fails to apply [source](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py).
Could you share a sample of your actual API request payload and the full response (including any error messages or unexpected results)? That will help pinpoint the issue. Also, double-check that your column names and filter values match the dataset exactly, and that you're using supported operators like `==`, `LIKE`, or `IN`. If you see a validation error or unexpected output, let me know what it says—I'll help you troubleshoot!
<!-- 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/43476f6a-1984-4eb4-a43b-9115305b680c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/43476f6a-1984-4eb4-a43b-9115305b680c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/43476f6a-1984-4eb4-a43b-9115305b680c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/43476f6a-1984-4eb4-a43b-9115305b680c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/43476f6a-1984-4eb4-a43b-9115305b680c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/43476f6a-1984-4eb4-a43b-9115305b680c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/43476f6a-1984-4eb4-a43b-9115305b680c?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/34668)
GitHub link: https://github.com/apache/superset/discussions/34668#discussioncomment-14091322
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Filtered Chart Data via API [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on the discussion: Filtered Chart Data via API
<!-- Greeting -->
Hi @satanic-panic! I'm [Dosu](https://go.dosu.dev/dosubot) and I’m helping the superset team.
<!-- Answer -->
Yes, you can filter chart data directly via the `/api/v1/chart/data` API endpoint by sending a POST request with a JSON payload. In your payload, include a `filters` array inside the `queries` list, where each filter specifies the column (`col`), operator (`op`), and value (`val`). Supported operators include `==`, `LIKE`, `ILIKE`, `IN`, and more.
Here's a minimal example for filtering by equality and LIKE:
```json
{
"datasource": "your_table_or_dataset_id__table",
"queries": [
{
"filters": [
{ "col": "ID", "op": "==", "val": 123 },
{ "col": "NAME", "op": "LIKE", "val": "%foo%" }
]
}
]
}
```
Replace `"your_table_or_dataset_id__table"` with your actual datasource identifier. The `filters` array can include as many filter objects as you need, using any supported operator.
Jinja templating and dashboard filters do not interact directly with this API call. Jinja is only relevant if you use it in the `where` or `having` clauses in the `extras` field of your query object, but for most use cases, specifying filters as shown above is the most straightforward approach for API-based filtering.
For more details, see the [relevant code and schema](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py) and [discussion on API usage](https://github.com/apache/superset/discussions/32117#discussioncomment-12041271).
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*
---
Docs are dead. Just use [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-tagline&utm_term=apache%2Fsuperset).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-feedback&utm_term=apache%2Fsuperset&message_id=e4347900-eed7-4dda-bc7d-de563b3a3983) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-ask-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=static-docs-share-team&utm_term=apache%2Fsuperset)
GitHub link: https://github.com/apache/superset/discussions/34668#discussioncomment-14091144
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [D] Filtered Chart Data via API [superset]
Posted by "dosubot[bot] (via GitHub)" <gi...@apache.org>.
GitHub user dosubot[bot] edited a comment on the discussion: Filtered Chart Data via API
<!-- Answer -->
Filtering via the `/api/v1/chart/data` endpoint is fully supported in Superset 4.1.3, and the payload should include a `filters` array inside each query object, with each filter specifying `col`, `op`, and `val` keys. If filtering isn't working, common causes are typos in column names, unsupported operators, datatype mismatches, or database driver limitations. The API will return a validation error if the payload is malformed, or sometimes a `rejected_filters` section in the response if a filter fails to apply [source](https://github.com/apache/superset/blob/829e4d92d91ceae4b43b1ed3b063ffe45377799c/superset/charts/schemas.py).
Could you share a sample of your actual API request payload and the full response (including any error messages or unexpected results)? That will help pinpoint the issue. Also, double-check that your column names and filter values match the dataset exactly, and that you're using supported operators like `==`, `LIKE`, or `IN`. If you see a validation error or unexpected output, let me know what it says—I'll help you troubleshoot!
<!-- Dosu Comment Footer -->
*To reply, just mention [@dosu](https://go.dosu.dev/dosubot?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=reply-with-mention&utm_term=apache%2Fsuperset).*
---
Share context across your team and agents. Try [Dosu](https://dosu.dev?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-tagline&utm_term=apache%2Fsuperset).
[](https://app.dosu.dev/response-feedback?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-feedback&utm_term=apache%2Fsuperset&message_id=43476f6a-1984-4eb4-a43b-9115305b680c) [](https://github.dosu.com/apache/superset?utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-learn-repo&utm_term=apache%2Fsuperset) [](https://app.dosu.dev/signup?referrer=openSource&source=github-footer&utm_source=github&utm_medium=bot-comment&utm_campaign=github-comment-footer-20260415&utm_content=knowledge-infrastructure-add-team&utm_term=apache%2Fsuperset)
GitHub link: https://github.com/apache/superset/discussions/34668#discussioncomment-14091322
----
This is an automatically sent email for notifications@superset.apache.org.
To unsubscribe, please send an email to: notifications-unsubscribe@superset.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org