Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

andersb's avatar

Saving API usage for metered billing

Do anyone use a good package for saving API usage in Laravel?

We would like to save the API usage for our users and potentially implement a metered billing at some point and are looking for a good solution for saving this.

Imagine for example that we have four endpoints

POST /api/posts
PUT  /api/posts
GET  /api/posts
GET  /api/post/{post}

Then we would like to save when a user requests a post, when they create a post, edit a post and so on.

We could build something for this ourself, but if there is already a package out there that we don't know about then it would be stupid to do so.

0 likes
1 reply
Braunson's avatar

I don't know of any handy package but I want to suggest using Middleware to do the counting for you, it abstracts that logic away from your API endpoint controller methods.

If you do build one, you should publish it as a package, I'm sure others would appreciate it :)

2 likes

Please or to participate in this conversation.