Is there an equivalent HTTP API to import a dashboard from grafana.com

In the Grafana UI it is possible to import a dashboard from grafana.com though an id. Is there an equivalent HTTP API call which allows me to install dashboards hosted on grafana.com programmatically?

Yes, bash example:

#!/bin/bash
### Please edit grafana_* variables to match your Grafana setup:
grafana_host="http://localhost:3000"
grafana_cred="admin:admin"
grafana_datasource="cloudwatch"
ds=(1516 677 139 674 590 659 758 623 617 551 653 969 650 644 607 593 707 575 1519 581 584 2969);
for d in "${ds[@]}"; do
  echo -n "Processing $d: "
  j=$(curl -s -k -u "$grafana_cred" $grafana_host/api/gnet/dashboards/$d | jq .json)
  curl -s -k -u "$grafana_cred" -XPOST -H "Accept: application/json" \
    -H "Content-Type: application/json" \
    -d "{\"dashboard\":$j,\"overwrite\":true, \
        \"inputs\":[{\"name\":\"DS_CLOUDWATCH\",\"type\":\"datasource\", \
        \"pluginId\":\"cloudwatch\",\"value\":\"$grafana_datasource\"}]}" \
    $grafana_host/api/dashboards/import; echo ""
done

Source: https://github.com/monitoringartist/grafana-aws-cloudwatch-dashboards

2 Likes

Thank you very much, you made my day and it works like a charm.

Is there a reason this is undocumented? http://docs.grafana.org/http_api/dashboard/

1 Like

@jangaraj I am unable to import my dashboards …trying like below

for d in $DASH_DIR/* ; do
curl -X “POST” $HOST
-H “Content-Type: application/json”
-d @$d
done
~

— $DASH_DIR/* has my exported .json files