Google App Engine
Feedback on this document

Creating an API server

In the following instructions, we describe using a separate module for the API server. However, it's not a requirement; you could just add the required endpoints.api_server code shown below to the module where you define your API. If you are defining only a single API, you may want to define the API server in the same file where you define your API because it doesn't need to import any other classes. If you are defining multiple APIs (remote.Service subclasses) that are defined in multiple files, it might be preferable to have a separate file for your API Server in order to import all these class files.

You must define an API server that uses the API or APIs you have created. To do this,

  1. Create a separate module, for example, services.py (you can use any name you want). The following sample shows what you would need to add to this file if you were exposing two classes (two APIs) in your endpoint:
    from google.appengine.ext import endpoints
    
    import your_api
    import your_other_api
    
    
    application = endpoints.api_server([your_api.YourApi,
                                        your_other_api.YourOtherApi],
                                        restricted=False)

    where your_api and your_other_api are the names of the modules containing the API classes you are exposing, and YourApi and YourOtherApi are the API class names.

  2. In your app.yaml file, map the API server you just created to the endpoints location as follows:
    handlers:
    # Endpoints handler
    - url: /_ah/spi/.*
      script: services.application

    where services is the file name you used for your API server module. Notice that the endpoints path is always /_ah/spi relative to the application.

Authentication required

You need to be signed in with Google+ to do that.

Signing you in...

Google Developers needs your permission to do that.