External HTTP API?

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?

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

What are you thinking of doing?

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.

Gotcha.

We’ll be improving the docs there!

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.

1 Like

Hey Alex,

Will will able to share that how you mange this?

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.

Are there any more updates on this?

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

I also recently came across: