-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Document the REST API #2689
Comments
Define "public" :) You are more than welcome to use the same RESTful/HTTP/JSON API we use to implement the frontend, however it is not yet well documented and we haven't made any promises about backwards compatibility in future versions (though we tend to not break existing APIs) Right now the easiest way to figure out the API is to look at the Clojure source in Here's an example: http://discourse.metabase.com/t/external-http-api/175/5 And here's the query language reference: https://github.com/metabase/metabase/wiki/Query-Language-%2798 I'll change the title to say we should document the API. |
Thank you! I ended up doing something like that (in Python): import json
headers = {
'Accept-Language': 'en-US,en;q=0.8',
'Origin': 'http://mymetabase.herokuapp.com',
'Host': 'mymetabase.herokuapp.com',
'Cookie': 'metabase.SESSION_ID=XXXXXXXX',
'Referer': 'http://mymetabase.herokuapp.com/q/b64stringhere',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36',
'Content-Type': 'application/json;charset=UTF-8'
}
payload = {
"database":2,
"type":"native",
"native": {
"query": "LONG SQL QUERY;"
}
}
url = 'http://mymetabase.herokuapp.com/api/dataset'
r = requests.post(url, data=json.dumps(payload), headers=headers)
output = json.loads(r.text) |
BTW, I believe sessions will expire after 2 weeks. I'd also recommend doing this over HTTPS, which should work out of the box on Heroku. |
You can always run You can view various endpoints by searching for |
Another good starting point is looking at |
Since this question is being asked in a lot of places let me summarize how to use the API again: Get a session token by hitting
|
I'm trying to run a query from the command line that gets the sum of all prices in the products table (i.e. source_table 3) from the given sample dataset (i.e. database 1). This is how it looks in SQL: This is what I executed in the terminal: However, it returned a "Malformed JSON in request body" error. I've tried changing up the |
"Malformed JSON in request body" means exactly what it says... It's probably easier to edit your JSON in an editor that validates the syntax and then copy that into the command line. |
I've written an official wiki page consolidating the vast troves of wisdom contained on this page. View the guide to using the REST API here: https://github.com/metabase/metabase/wiki/Using-the-REST-API This page also has a link to our new complete list of API endpoints from PR #3630. Since this is now implemented I'm going to go ahead and close this out. |
Hey guys, is there a public API to get the data I have queried in Metabase to external services, like zapier?
The text was updated successfully, but these errors were encountered: