umami icon indicating copy to clipboard operation
umami copied to clipboard

Raw data JSON API

Open juanitoddd opened this issue 6 years ago • 6 comments

Hello @mikecao, first of all, thanks for this awesome contribution !

I just wanted to ask you if there has been plans to have an API for the raw data as JSON

Regards

juanitoddd avatar Nov 14 '20 19:11 juanitoddd

The app itself uses API calls to get data. It's not documented but you can watch your network requests to make the same calls or look through the source code.

mikecao avatar Nov 15 '20 11:11 mikecao

Thank you !

juanitoddd avatar Nov 15 '20 13:11 juanitoddd

But how to handle auth in that case ?

abathellier avatar Nov 18 '20 11:11 abathellier

What I did was to make a HTTP request to the auth endpoint:

POST [localhost:3000]/api/auth/login data: { username: 'admin', password: ***** (your pass)}

this will return a token, this token then you pass on every other Request as a cookie with the key "umami.auth". For example to create a new website:

POST [localhost:3000]/api/website headers: { 'cookie': "umami.auth=[THE_TOKEN]"} data: { name: [MY_WEB], domain, etc....}

juanitoddd avatar Nov 18 '20 11:11 juanitoddd

@juanitoddd thank you i'll try

abathellier avatar Nov 18 '20 11:11 abathellier

Just in case someone else is running into this, I wrote myself a small API wrapper in JS to access the umami data. Might be useful to someone else: https://gist.github.com/joshinat0r/8f3428ab0a1de834d07efd29703c2c3f

joshinat0r avatar Feb 02 '21 15:02 joshinat0r