google drive api python - python

I want to write a desktop python app using google drive API but the documentation on google website is a little messy and twisted with drive sdk which makes thing complicated and difficult to find useful staffs.
Can anyone give some useful doc and some sample code?
Thx~

When using Twisted, you will need to adopt a policy whereby every Drive API call is deferred to a thread or threadPool. I recently wrote a blog post about it here:
http://unpythonic.blogspot.com/2012/07/calling-google-drive-api-and-other.html

Related

Which Python Cloud Storage lib/API is "officially" supported by Google?

I'm migrating a Python service out of Google App Engine over to GCE/GKE and could use some help identifying the current production-grade, SLA'd method for managing objects in Google Cloud Storage.
The one referenced by most of Google's storage docs is the google.cloud.storage library. This looks nice and simple. However, as of now -- Jan 2017 -- there's a big header at the top that identifies the library as Beta, and has no SLA or deprecation policy. I'd prefer to use an SLA'd service.
After a lot of searching I found this alternative JSON API example:
https://github.com/GoogleCloudPlatform/storage-file-transfer-json-python
but it's much more cumbersome and isn't clear that it's better supported.
Any advice on which API to use?
Or better examples for bootstrapping?
Thanks in advance
Google Cloud Storage, the service, is not in beta. It has an SLA and a deprecation policy. The client library you've found, the Google Cloud Client Library for Python (google-cloud), is in beta, which means that it's possible that a future version of it might in some cases make backwards-incompatible changes. However, it's also the current gold standard for easiest-to-use client library.
I recommend you use that one. Another option is the Google Python API Client Library, which is not in beta, but I found the Google Cloud Client Library for Python to be substantially easier to use, which is important.

Examples for using Google Admin SDK API (python)

We use Google Apps at my organization. I am trying to just use my API key (no oauth2) to get access to users info through the Directory API in the Admin SDK. I cannot find useful examples and the Google docs are buggy. I have had a great deal of difficulty with Google's API documentation. Or perhaps I have to use oauth2?
Even if I knew some of the details about this specific API, I can't find sample code for using these APIs in Python. Does anyone have sample code or links to real-world samples? I am new to Python and we're working on the App Engine.
You must use OAuth2 authentication, API key alone is not enough as you must authenticate as a Google Apps super admin or delegated admin (with appropriate rights) in order to perform Admin SDK Directory operations.
My project, Dito GAM was recently updated with full support for Admin SDK calls. It makes use of most (all?) Directory API calls. See:
https://code.google.com/p/google-apps-manager/source/browse/trunk/gam.py
Also, if you notice bugs or ambiguities in the Google documentation, be sure to report them. It won't get any better if someone doesn't tell them about it! Use the "Report a bug" link at the bottom of all developers.google.com pages. It's very simple to use and pinpoint the exact issue.

Use oauth to connect GAE python application to google's drive/docs/spreadsheet

I'd like to allow my Google App Engine application to connect to a clients Google Spreadsheet on their Google Drive. I've spent the last two and a half days trying, and I've gotten nowhere. Half of the GAE Python documentation seems to be out of date. For example some of the examples have webapp, and they don't work until I change them to webapp2, but that doesn't always work.
I created a OAuth2.0 thing (not really sure what to call it) at:
https://code.google.com/apis/console/
So now I have a Client ID and Client Secret, but one doc talked about a CONSUMER_KEY and CONSUMER_SECRET. So are they the same or?
I followed the following doc to use OAuth to read my tasks (I know it's a different API), but I couldn't figure out step/Task 3. I'm not sure if I have all of the files/librarys to connect using OAuth. I have the gdata-2.0.17 files, and I know how to connect to the drive and spreadsheets by hard coding the login credentials, but no user is going to give me their credentials.
I don't normally ask for code, or even help, but I'm completely lost with this whole OAuth API/Service.
If someone could post some sample code that uses OAuth 2.0 and webapp2, and that you have tested, that would be awesome.
If someone could link me to a sample GAE Python project that can authenticate with Google's servers and allow it to connect to the users spreadsheets using OAuth 2.0 and webapp2, I'd be over the moon.
A complete example application using Google Drive from GAE is explained in this article.
See Retrieving Authenticated Google Data Feeds with Google App Engine (Python) if you need to access the spreadsheet content.
The samples in this article is using Google Document List API but it could be easily adapted to use spreadsheets scope and spreadsheet client or service.
If you only need to list the files, I would recommend using Drive like #SebastionKreft suggested

Using Hunch on Google App engine

I want to use Hunch on Google App Engine in Python. What libraries do I need to use to do this or are there any good online tutorials that could help me with this?
I would start from the API Overview documentation of the official site.
Basically Hunch API calls are authenticated GET or POST HTTP requests where the returned values are JSON encoded.
Example:
get the list of the top recommended movies:
http://api.hunch.com/api/v1/get-recommendations/?topic_ids=all_544&limit=10
get-recommendation is just one of the many available routes that Hunch API offers; to get an overview of all the available methods, have fun playing with the API console.
On google App Engine you would need:
UrlFetch API to make the HTTP Api calls
simplejson to decode the results
Here are a couple of Hunch GAE projects that should help you to get started:
hunch-gift-app
hunch-sample-app
As referenced by gleitz, you can find a Python wrapper here.
Recently, mnn2104 wrote a Python wrapper for the Hunch API called HunchPY.
As for tutorials, a good place to start is the the Hunch Developer homepage and Hunch's Github profile.

Bloomberg Server API and Ruby/Python

Im looking to write a new application in ruby/python which uses a feed from bloomberg and am stuck trying to find any documentation for using (or even setting up) Bloomberg Server API with either of these languages.
Does anyone have any good links to tutorials for this or maybe some boilerplate code to get set up? Or is it best to just stick to the three main supported languages?
The Bloomberg Open API (BLPAPI) v3.5 release now includes a native Python SDK.
http://www.openbloomberg.com/2012/11/21/open-api-blpapi-v3-5-x-released/
Did you check out some questions at SO on this. It might help you
Bloomberg API request timing out
Asynchronous data through Bloomberg's new data API (COM v3) with Python?
Resolver is an spreadsheet implementation in IronPython and has a very good integration for Bloomberg API
http://www.resolversystems.com/documentation/apidocs/MarketData_Bloomberg.html
Here is a simple Client access API which I wrote with the help of the mentioned links as well as some others. Not everything is implemented but it is a good start.
https://github.com/bpsmith/pybbg

Categories

Resources