Question

I have programmed and tested my API using Proto-datastore and now I'm ready to do something more with it.

As well as having generated the client library to allow apps to communicate with the API, I'm looking to create a web-based 'Dashboard' for the service (which would be based on the guestbook example). This would be also be built and hosted on the same App-Engine project. But I have no idea how to go about consuming the API in App Engine.

Importing the API and just calling the @Model.method() decorated functions won't work. I have found this but I was wondering if there's anything in proto-datastore I've missed that would let me do this?

Was it helpful?

Solution

The way I'm doing it is to access the endpoint, the same way I would access any other Discovery-based API hosted somewhere else, by using use the Google APIs Client Library for Python which is compatible with endpoints.

Normally you would build a client for one of the Google APIs 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()

Might not be the most optimal way, but it works like a charm.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top