API calls overview

The API allows HTTP GET, HTTP POST, and HTTP DELETE calls.

GET is used to retrieve data (JSON format), POST is used to add/update data (for example, adding a new alert subscriber), and DELETE is used to delete data (for example, deleting a user).

All of the GET API calls can be easily tested with a browser (just paste the full URL and you will receive the JSON output on your screen).

For POST and DELETE, you will have to use cURL, write your own code, or use the tools available for working with REST API calls.

The paths presented here are relative to the root path of Redash.

For example, if my Redash is located at myredash.mydomain.com and I'm interested in the API located at /api/alerts, then the full URL will be http://myewdash.mydomain.com/api/alerts.

Let's make an example API call to retrieve the query details of the query with id=7034. I will be using curl the command; the api_key should be obtained. In this example, I'm using the Redash located at demo.redash.io. It is publicly accessible, so you will be able to see the results by executing the following command on your own computer, too:

cURL: http://demo.redash.io/api/queries/7034?api_key=PVZnoWp8dzpOc39nqrltmhShKgC712k2I67M0zWR.

The results are returned as JSON:

{
"latest_query_data_id": 4858254,
"schedule": null,
"is_archived": false,
"updated_at": "2018-06-19T13:59:14.086188+00:00",
"user": {
"auth_type": "external",
"created_at": "2018-03-25T22:47:14.445079+00:00",
"name": "Alexander Leibzon",
"gravatar_url": "https://www.gravatar.com/avatar/ec8c207871ac01f536886d27d80d215d?s=40",
"updated_at": "2018-03-25T22:47:14.445079+00:00",
"id": 31659,
"groups": [2],
"email": "[email protected]"
},
"query": "select count(*) from queries;",
"is_draft": true,
"id": 7034,
"description": null,
"can_edit": false,
"name": "inner_test1",
"created_at": "2018-06-11T14:44:52.260418+00:00",
"last_modified_by": {
"auth_type": "external",
"created_at": "2018-03-25T22:47:14.445079+00:00",
"name": "Alexander Leibzon",
"gravatar_url": "https://www.gravatar.com/avatar/ec8c207871ac01f536886d27d80d215d?s=40",
"updated_at": "2018-03-25T22:47:14.445079+00:00",
"id": 31659,
"groups": [2],
"email": "[email protected]"
},
"version": 1,
"query_hash": "8edff20893be2fe567819947d9735177",
"visualizations": [{
"description": "",
"created_at": "2018-06-11T14:44:52.260418+00:00",
"updated_at": "2018-06-11T14:44:52.260418+00:00",
"id": 10603,
"type": "TABLE",
"options": {},
"name": "Table"
}],
"api_key": "PVZnoWp8dzpOc39nqrltmhShKgC712k2I67M0zWR",
"options": {
"parameters": []
},
"data_source_id": 2
}

Note that, in case you forget about the authentication and try to make a call without api_key, you will get the following error:

curl http://demo.redash.io/api/queries/7034
{
"message": "Couldn't find resource. Please login and try again."
}

This is an overview of all the possible API calls supported in Redash.

You can find them all in the api.py file (located in $REDASH_DIR/redash/handlers/api.py).

In this secion, the API calls are grouped by themes, with explanations about every group of API calls:

  • Alert: related API calls allow us to View/Add/Modify alerts, as well as add and remove subscribers to/from a certain alert:
  • /api/alerts 
  • /api/alerts/<alert_id> 
  • /api/alerts/<alert_id>/subscriptions 
  • /api/alerts/<alert_id>/subscriptions/<subscriber_id> 
  • Dashboard: related API calls allow us to View/Add/Modify dashboards, see a recent dashboard, list public ones, and share them (allowing anonymous access to the dashboard):
  • /api/dashboards
  • /api/dashboards/recent
  • /api/dashboards/<dashboard_slug>
  • /api/dashboards/public/<token>
  • /api/dashboards/<dashboard_id>/share
  • Data source: related API calls allow us to view, modify, add, and delete data sources, as well as test the connection, get the schema (for a specific data source), and pause a specific data source:
  • /api/data_sources
  • /api/data_sources/types
  • /api/data_sources/<data_source_id>/schema
  • /api/data_sources/<data_source_id>/pause
  • /api/data_sources/<data_source_id>/test
  • /api/data_sources/<data_source_id>
  • Group-related API calls allow us to view, modify, add, and delete groups, manage users as members of groups, and manage data sources as members of groups:
  • /api/groups
  • /api/groups/<group_id>
  • /api/groups/<group_id>/members
  • /api/groups/<group_id>/members/<user_id>
  • /api/groups/<group_id>/data_sources
  • /api/groups/<group_id>/data_sources/<data_source_id>
  • The following is an API call that shows all the recent events that have occurred in the system: 
  • /api/events
  • Query: related API calls allow us to view, modify, add, and delete queries, as well as view recent/user-only queries, search queries, trigger query results and refresh them, fork a query, and download its dataset as a .csv/.json file:
  • /api/queries
  • /api/queries/search
  • /api/queries/recent
  • /api/queries/my
  • /api/queries/<query_id>/refresh
  • /api/queries/<query_id>
  • /api/queries/<query_id>/fork
  • /api/queries/<query_id>/results.<filetype>
  • /api/queries/<query_id>/results/<query_result_id>.<filetype>
  • ACL (Access Control List): related API calls and API calls related to security allow us to view and modify the access policy on a certain object (a query, widget, dashboard, and so on):
  • /api/<object_type>/<object_id>/acl
  • /api/<object_type>/<object_id>/acl/<access_type>
  • Query results: related API calls allow us to view and download query results:
  • /api/query_results
  • /api/query_results/<query_result_id>.<filetype>
  • /api/query_results/<query_result_id>
  • Job: related API calls allow us to retrieve information about a running query job or cancel a running query job:
  • /api/jobs/<job_id>
  • Users: related API calls allow us to view, modify, add, and disable users, invite users by email, and reset a user's password:
  • /api/users
  • /api/users/<user_id>
  • /api/users/<user_id>/invite
  • /api/users/<user_id>/reset_password
  • /api/users/<user_id>/disable
  • Visualization: related API calls allow us to view, modify, add, and delete visualizations:
  • /api/visualizations
  • /api/visualizations/<visualization_id>
  • Widgets: related API calls allow us to view, modify, add, and delete widgets:
  • /api/widgets
  • /api/widgets/<int:widget_id>
  • Alert destinations: related API calls allow us to view, modify, add, and delete Alert type destinations:
  • /api/destinations
  • /api/destinations/types
  • /api/destinations/<destination_id>
  • Query snippets related to API calls allow us to view, modify, add, and delete query snippets:
  • /api/query_snippets
  • /api/query_snippets/<snippet_id>
  • API- related global Redash settings allow us to View/Add/Modify global settings (for example, date_format, Google app domains, and so on):
  • /api/settings/organization
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
52.14.149.128