Reputation: 23747
Is there any software I can install that will give me information about my API usage in Rails? I see some API management services but they are all VERY expensive and very complex. I want something to give me basic information about my API.
Also, log analysis seems a way to go. However, I'd like to know if this is the solution that is most used by companies right now. They must use something?
Thanks
Upvotes: 1
Views: 134
Reputation: 15530
if your users already have API key, you can track the activity by following code:
#applications_controller.rb (controller)
after_filter :track_api_usage
private
def track_api_usage
current_user.api_tracking(params) if params[:api_key]
end
#user.rb (model)
has_many :trackings
def api_tracking(params)
trackings.create(self.id, params)
end
Upvotes: 1
Reputation: 20769
Why not add an API key which users of your api need to register for, like google maps. Make it as easy as possible otherwise they wont use your api. Having a key for your API means you can prevent usage abuse of your API. I.e. if there is too much traffic from a registered address then you can cut them off.
Upvotes: 0