5

I am looking to add some sort of analytics to my Tastypie-powered API. I really enjoy Google Analytics for the regular web site however obviously it won't work for an API. How do you do analytics for APIs in general? And are there any packages available for Tastypie which add analytics - at least some basics: resource url, time, agent, request headers, etc?

While I use Tastypie, the same question can be asked of django-piston and django-rest-framework.

JCotton
  • 11,650
  • 5
  • 53
  • 59
miki725
  • 27,207
  • 17
  • 105
  • 121

2 Answers2

3

If you use throttle = CacheDBThrottle() in your resource, you can see resource url, time, request method and identifier (if you're using authentication) in tastypie_apiaccess table. However, other information like IP, country, user agent, request headers etc. are still missing. You can use make your own throttle class and a model to save this information.

Another approach can be to use some tool to analyze your server logs.

Irfan
  • 684
  • 5
  • 15
0

Yet another tool you could try is Qmonix. It's analytics SDK that allows you to push any kind of events.

Events are encoded like this "my_app/event/happened".

Events are sent over HTTP API so you can use Qmonix in your web apps.

Unfortunately, there is no Tastypie lib for this, but well you are still able to easily write your own wrappers to send your events over HTTP.

You can take a look at other langugage libs (JavaScript, Android, etc.) at github.

PovilasB
  • 1,488
  • 1
  • 15
  • 25