0

I want to use python google api client library to retrieve the data of my google slide. The python code should be equivalent to this REST API call in term of outcome.

GET https://slides.googleapis.com/v1/presentations/GXGXGXGXGXGXGXuf3LAMp0I89qfQYv6ffHRmI?key={YOUR_API_KEY}

So in the frontend/javascript side, I use the picker API to return me a file id. I can use the file id to download the slide as a pdf file

However, when i tried to use the slides api,

http = httplib2.Http()
http_auth = credentials.authorize(http)

slide_service = build('slides', 'v1', http=http_auth)
p = slide_service.presentations(fileId).get()
print p

I get the exception TypeError: methodResource() takes exactly 1 argument (2 given)

I tried to use the file id as parameter of the get method, like so:

p = slide_service.presentations().get(fileId)

Again it failed with this error: TypeError: method() takes exactly 1 argument (2 given)

There is basically no documentation of the function synature of these python APIs. What is the right way to retrieve the slide data?

Anthony Kong
  • 37,791
  • 46
  • 172
  • 304

2 Answers2

0

Based on the API explorer, the get method takes a parameter presentationId

enter image description here

So the python code should be

p = slide_service.presentations().get(presentationId=fileId)
Anthony Kong
  • 37,791
  • 46
  • 172
  • 304
-1

The pydoc for all Google APIs are available here:

https://developers.google.com/api-client-library/python/apis/

The Slides specific one, for example, is here:

https://developers.google.com/resources/api-libraries/documentation/slides/v1/python/latest/

Maurice Codik
  • 598
  • 2
  • 6
  • The link you cited is not the API i am asking in the question – Anthony Kong Aug 02 '17 at 21:10
  • I'm pretty sure it is. You're using `apiclient.discovery` as described [here](https://developers.google.com/api-client-library/python/start/get_started#build-the-service-object)? That pydoc explains the objects returned by build(), as in your code snippet. – Maurice Codik Aug 03 '17 at 22:04
  • I thought `apiclient` is the old library? I read somewhere that `googleapiclient.discovery` is recommended. – Anthony Kong Aug 04 '17 at 01:14
  • In the latest lib, `apiclient` is an [alias](https://github.com/google/google-api-python-client/blob/master/apiclient/__init__.py) for `googleapiclient`. On the [python library README](https://github.com/google/google-api-python-client#about), there's a 'dynamically generated documentation' link that points to the same https://developers.google.com/api-client-library/python/apis/ page I linked above. – Maurice Codik Aug 04 '17 at 14:25