Showing stats on an HTML page using the API

This is what I’m trying to implement. I have a static blog using Jekyll and I want to add a small javascript code that will show the view count for the individual page. I’m thinking this can be done using the API. But, that would mean embedding the token in the javascript code. Is there a way to do this without allowing anonymous access?
Or, is there a way to have a token that will have permission to only view a few statistics? Thanks :slight_smile:

I dont know Jekyll, but if it is PHP you could simply do the API call via cURL.

Thanks for the response. I can make the API request without any issue, I was concerned about the part with the token being exposed on the website while using javascript.

Yes, this is why I asked if it is possible to make the call on the server side.

Hi, unfortunately such selective access isn’t possible at the moment.

So the only solution is writing a really minimal server that forwards this one API call to the visitor.

Of course as this is a static page, there might be another way if you have access to the server. You could write a small cronjob that downloads the API every X minutes and saves it into a file. This file could then be requested via JS.

1 Like

That sounds like a good idea. Thank you so much. I’ll give it a try :slight_smile:

1 Like