I think google’s API and its Python binding are a huge mess.
And poor documentation makes them even worse.
You can find the majority of parameters described in quite understandable way, but you can’t start using them because you have to authorize first, and this topic is among worst explained.
But even if you passed it, you’re stuck with some tricky params that you have to discover SOMEHOW.
Example: for exporting data from GA you have to provide some PROFILE ID (it is often called the TABLE ID in the docs).
Great, have a nice time clicking around your account settings trying to find it.
UPD: I thought the only way to solve it is like that: http://blog.explainum.com/2011/05/how-to-find-profileid-in-new-google.html
But there’s actually an ‘official’ way – click your account settings, then on the Profiles tab pick the profile and click the profile settings tab.
The ID is actually there.
Another nice example – they have the API Key. But it’s not supported by the library so if you’re going to collect some stats on the server, you have to store your email / password, or to mess with OAuth.
And another point. You start with creating a service like
service = gdata.analytics.service.AnalyticsDataService(
source=settings.GA_APP_NAME,
email=settings.GA_USERNAME,
password=settings.GA_PASSWORD
)
1 2 3 4 5 |
service = gdata.analytics.service.AnalyticsDataService(
source=settings.GA_APP_NAME,
email=settings.GA_USERNAME,
password=settings.GA_PASSWORD
)
|
Good, then try requesting your data — even though you’ve provided your credentials, this bitch didn’t authorize you. Cool?
Call
, then you’re done.