"Data source" means something specific in Grafana. Prometheus data source has a well defined path for its queries; you can't modify that. There is an HTTP JSON+API datasource for Grafana if you search its plugins - https://marcus.se.net/grafana-json-datasource/
However, that's completely bypassing Prometheus longer-term storage. Prometheus reads scrape targets, then collects and aggregates that.
To do so, your API would need to expose any route that returns Prometheus "exposition format", not JSON. This route is put in the Prometheus config file, not into Grafana anywhere.
While Prometheus can load random data, it's better to use Counter, Guage, etc types it expects
The OpenTelemetry project should be able to be used in any framework, and there are examples in their documentation for the Python module.
If your goal is to just get any data, not metrics, into Grafana, using an RDBMS or Mongodb, or other supported data sources might be better
Answer from OneCricketeer on Stack Overflow