Deploying and testing an API

This page describes how to deploy your API.

Before you begin

Deploying your API to production

To deploy an API:

  1. Set the ENDPOINTS_GAE_SDK environment variable to the path of your App Engine SDK folder: Path_to_Cloud_SDK/platform/google_appengine.

    Replace Path_to_Cloud_SDK with the output of the following command:

     gcloud info --format="value(installation.sdk_root)"
  2. Run the following command in the API main directory:

     gcloud app deploy

    Wait a few moments for the deployment to succeed, ignoring the warning messages. When the deployment completes, a message similar to the following displays:

    File upload done.
    Updating service [default]...done.
  3. Confirm successful deployment by sending a test request to the API, for example:

    curl --request POST \
       --header "Content-Type: application/json" \
       --data '{"content":"echo"}' \

    Replace PROJECT_ID with your project ID and echo with your API name.

    The results are:

     "content": "echo echo"

If you didn't get a successful response, see Troubleshooting response errors.

Deploying to multiple app versions

For information on how to do API versioning, and how to deploy to versions, see Handling API versioning

Testing an API locally

You can use the App Engine local development server to test your API locally. For more information about the local development server, see Using the local development server.

To run your API locally:

  1. From the root directory of the project, start the App Engine development server: YOUR_PROJECT_DIR
  2. Run curl to make an API request, for example:

     curl --request POST \
        --header "Content-Type: application/json" \
        --data '{"message":"echo"}' \

Adding API management

Endpoints Frameworks provides API management features such as:

For your API to be managed by Endpoints Frameworks, you must generate and deploy an OpenAPI document that describes your API, as described in Adding API management.