2

I've found two different APIs to interact with google spreadsheets, but don't know which is the one I should use. I found these two: 1. google-api-python-client: http://github.com/google/google-api-python-client 2. gdata-python-client: https://code.google.com/p/gdata-python-client/

I thought the first one was the correct one but I can't find the way to get a spreadsheet's content.

By 'correct' I mean 'able to upload a new spreadsheet and modify or delete an existing one'. Thanks for your help.

huapito
  • 395
  • 2
  • 10

1 Answers1

2

The Google API Python Client and the Google Data Python Client can access different APIs. As far as I understand, Google is migrating older APIs of their services to provide developers a clean and unified access to all services.

Google API Python Client is newer and meant for the newer Google API, including Google Drive API, which allows you to create/delete spreadsheets for example or access meta-data of spreadsheets. You cannot modify the content of these files. This library supports oAuth 2 for authentication, including service-accounts.

Google Data Python Client is much older and a little bit outdated and cumbersome. It provides you with access to the (older) Google Data API, including Google Spreadsheets API 3.0, which allows you to add/remove worksheets to/from a spreadsheet, querying or adding rows or cells, or modifying cells/rows. However, the Google Data API and so the Spreadsheets API feel very different from the other APIs, especially the newer ones.

Some tips: For spreadsheets, you will find many examples using the older SpreadsheetService, but I think the Service class restricts you to oAuth 1. For oAuth 2 you would need to use the newer SpreadsheetClient class. They also have different method names and some concepts are different too. If you don't want to use a normal Google user account, but need to use a service account (with a p12 file created in the developer console), you can find a working code pattern here.

UPDATE: You may also want to have a look into the gspread library. It's supposed to be much easier than gdata, but I haven't figured out yet oAuth2 service account authorizations with that one.

Community
  • 1
  • 1
Ani
  • 1,377
  • 1
  • 18
  • 29