API to get dashboards and Panels?

Hi, I’m creating a webpage where I display all the different panels I have in my dashboards. Now I have all my panels embedded “Hardcoded” I got the URL “http://grafana.staged-by-discourse.com/d-solo/aodKZLBMk/influx?orgId=1&panelId=” And then I have a list with different ID from my Grafana: List[“2”, “4”, …] so, I have a loop where I create a

with all the graphs from my List.

But I would like to create in my webpage a configuration section, so I don’t have in my code the List. And I was wondering if there is an API to call Grafana and ask for all my dashboards and all my panels on my dashboard in order to get the different ID’s.

You can use the “search endpoint” to get a list of all your dashboards: Folder/Dashboard Search HTTP API | Grafana Labs

Beyond that, though, in order to get a list of panels in a given dashboard, you’ll need to parse the actual dashboard definition (from the dashboard API: Dashboard HTTP API | Grafana Labs)

@ramondonadeucaballer there is a years-long discussion on this Gist that might prove useful for you:

Seemed not to work, maybe older version?
I modified it using jq and based on uid

	mkdir -p ${ROOT_DIR}/dashboards
	for uid in $(curl -sk -H "Authorization: Bearer ${GRAFANA_API_KEY}" ${GRAFHOST}/api/search | jq '.[].uid' -r); do 
		curl -sk -H "Authorization: Bearer ${GRAFANA_API_KEY}" ${GRAFHOST}/api/dashboards/uid/$uid | jq . > ${ROOT_DIR}/dashboards/$uid.json 
	done

maybe another approach

https://github.com/yosiasz/grafanadashboards/blob/main/src/automate/exportalldashboards.py

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.