This page describes how to deploy your API.
Before you begin
- Set up your programming environment.
- Create an API and annotate it.
Deploying an API
You can deploy your API using the App Engine Apache Maven or Gradle plugins. To deploy your API to a production App Engine standard environment, use the command for your plugin:
- Use the command for your plugin:
Maven
mvn appengine:deploy
Gradle
gradle appengineDeploy
- Wait for the deployment to finish.
Send a test request to your deployed API. For example, using
curl
:curl \ -H "Content-Type: application/json" \ -X POST \ -d '{"message": "echo"}' \ "https://YOUR-PROJECT-ID.appspot.com/_ah/api/echo/v1/echo?n=2"
Your response is similar to the following:
{ "message": "echo echo" }
If you didn't get a successful response, see Troubleshooting response errors.
Deploying to multiple application versions
For information on how to do API versioning, and how to deploy to versions, see Handling API versioning
Running and testing API backends locally
To test your API locally:
Build the project in the root directory of the project. For example:
Maven
mvn clean package
Gradle
gradle clean build
Start the App Engine development server. For example:
Maven
mvn appengine:run
Gradle
gradle appengineRun
Make an API request to test your API. For example, using
curl
:curl \ -H "Content-Type: application/json" \ -X POST \ -d '{"message": "echo"}' \ "${HOST}/_ah/api/echo/v1/echo?n=2"
Serving your API from a different path
To serve your API from a different path, in your web.xml
file, change the
url-pattern
in the EndpointsServlet
section and redeploy your API. For
example:
<servlet-mapping>
<servlet-name>EndpointsServlet</servlet-name>
<url-pattern>/example-api/*</url-pattern>
</servlet-mapping>
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.