Consuming Gae Endpoints With A Python Client
I am using Google AppEngine Endpoints to build a web API. I will consume it with a client written in Python. I know that scripts are provided to generate Android and iOS client API
Solution 1:
You can use the Google APIs Client Library for Python which is compatible with endpoints.
Normally you would build a client using service = build(api, version, http=http)
for example service = build("plus", "v1", http=http)
to build a client to access to Google+ API.
For using the library for your endpoint you would use:
service = build("your_api", "your_api_version", http=http,
discoveryServiceUrl=("https://yourapp.appspot.com/_ah/api/discovery/v1/""apis/{api}/{apiVersion}/rest"))
You can then access your API with
result= service.resource().method([parameters]).execute()
Solution 2:
Here's what happens with the endpoints helloworld greetings example:
__author__ = 'robertking'import httplib2
from apiclient.discovery import build
http = httplib2.Http()
service = build("helloworld", "v1", http=http,
discoveryServiceUrl=("http://localhost:8080/_ah/api/discovery/v1/apis/helloworld/v1/rest"))
print service.greetings().listGreeting().execute()['items']
"""
prints
[{u'message': u'hello world!'}, {u'message': u'goodbye world!'}]
"""
Right now I'm using http.
Post a Comment for "Consuming Gae Endpoints With A Python Client"