External HTTP API?


#1

Does Metabase contain an HTTP API that I can use to run queries and consume data from? I realize there’s an internal API used by the web interface but there doesn’t seem to be any documentation on usage so I suspect it’s not meant for external use. The README mentions a Query API under the “Extending and Deep Integrations” section. Is this the same thing I am thinking of?


JSON URL to Access Table Data
#2

Yes. We’re planning on documenting that internal API in more detail.

What are you thinking of doing?


#3

I’ve managed to be able to authenticate as an existing user and run a simple query after digging through the server/front end code. My goal is to be able to run queries from an API and then feed that into something else.


#4

Gotcha.

We’ll be improving the docs there!


#5

For anyone else curious for the very basics of how to do this, here’s a curl example:

curl -X POST \
    -H "Cookie: metabase.SESSION_ID=XXXXXXXXXXXXXXX" \
    -H "Content-Type: application/json" \
    -d '{"database":1"type":"query","query":{"source_table":2,"aggregation":["rows"],"breakout":[],"filter":[]}}' \
    http://localhost:3000/api/dataset

(XXXXXXXXXXXXXXX is the value of a user’s session cookie. There’s also a X-METABASE-APIKEY header but I’m not sure if/how that works)

You can grab an existing query from your browser’s network panel or the server logs, or construct one using the query language.


Any API or programmatic way to add users
#6

Hey Alex,

Will will able to share that how you mange this?


#7

If you’re still wondering about this, what you can do is run some queries in Metabase and inspect network traffic in Chrome to get an idea of what the endpoints are and how the payloads are formatted.


#8

Are there any more updates on this?


#9

This got me started with the API: https://github.com/metabase/metabase/wiki/Using-the-REST-API

I also recently came across: