How to track WordPress REST API usage stats?
It has been a long time that WordPress has had the top market share among the Content Management Systems. Flexibility and ease of use are the key reasons why WP has been successful. Not only is WordPress comfortable for the end users, but also it is super easy for any PHP developer to quickly get started with theme and plugin development for it.
One of the most interesting features that WP delivers out of box is it’s native API system which allows developers to add their desired API endpoints via plugins (or even themes). As such I can name WooCommerce REST API which provides endpoints for almost every action possible associated with WooCommerce e-commerce platform.
An important aspect of every Website/App is to track page views and usage. Setting up a statistical tool like Google Analytics or plugins like WP Statistics would probably solve the problem, However, there are not much tools to track usage of your WordPress website’s API endpoints.
What is API Stats wordpress plugin?
In this article I’m introducing the WP API Stats plugin which I’ve developed to make develpers and site owners able to view and track usage of their WordPress blog’s API usage via WordPress dashboard. For now, the plugin covers some essential features but more features will be added on the long run.
How to use API Stats?
As for now, It’s pretty simple and easy to use. After installing the plugin from WordPress plugin directory and activating it, API Stats’s menu will be available in dashboard’s side menu. The logged in user must have the “manage_options” capability in order to view this page on wp-admin panel.
Inside the page, there are date filters to declear the date range. beside them is the “points” option. It defines duration of time between points on the chart. However, in order improve usability, it would automatically adjust to larger spans to prevent too many points on the stats chart and high server and browser load.
At the inner top part of the chart you can toggle different request methods. this can be very helpful specially when you want to view lower count methods such as DELETE or PATCH.
What is Next?
How to contribute?
As I mentioned before, I would be glad to receive suggestions. Also, I strongly appreciate if you inform me about bugs or issues. For user level issues you can submit a ticket on WordPress support and for developer level issues or contributions Github would be great.