Menu
Amazon API Gateway
Developer Guide

Generate SDK for an API

To call your API in a platform- or language-specific way, you must generate the platform- or language-specific SDK of the API. Currently, API Gateway supports generating an SDK for an API in Java, JavaScript, Java for Android, and Objective-C or Swift for iOS.

This section explains how to generate an SDK of an API Gateway API and demonstrates how to use the generated SDK in a Java app, a Java for Android apps, Objective-C and Swift for iOS apps, and a JavaScript app.

To facilitate the discussion, we refer to this API Gateway API, which exposes this Simple Calculator Lambda function.

Before proceeding, make sure you create or import the API and deploy it at least once in API Gateway. For instructions, see Deploying an API.

Generate SDKs for an API Using the API Gateway Console

To generate a platform- or language-specific SDK for an API in API Gateway, you must first create, test, and deploy the API in a stage. For illustration purposes, we use the Simple Calculator API as an example to generate language-specific or platform-specific SDKs throughout this section. For instructions on how to create, test, and deploy this API, see Create the Simple Calculator API.

To generate the SDKs of an API in API Gateway

  1. Sign in to the API Gateway console at https://console.aws.amazon.com/apigateway.

  2. In the box that contains the name of the API for the stage, choose Stages.

  3. In the Stages pane, choose the name of the stage.

  4. On the SDK Generation tab, for Platform, choose the platform.

    1. For Java, specify the following:

      • For Service Name, specify the name of your SDK. For example, SimpleCalcSdk. This becomes the name of your SDK client class. The name corresponds to the <name> tag under <project> in the pom.xml file, which is in the SDK's project folder. Do not include hyphens.

      • For Java Package Name, specify a package name for your SDK. For example, examples.aws.apig.simpleCalc.sdk. This package name is used as the namespace of your SDK library. Do not include hyphens.

      • For Java Build System, type maven or gradle to specify the build system.

      • For Java Group Id, type a group identifier for your SDK project. For example, my-apig-api-examples. This identifier corresponds to the <groupId> tag under <project> in the pom.xml file, which is in the SDK's project folder.

      • For Java Artifact Id, type an artifact identifier for your SDK project. For example, simple-calc-sdk. This identifier corresponds to the <artifactId> tag under <project> in the pom.xml file, which is in the SDK's project folder.

      • For Java Artifact Version, type a version identifier string. For example, 1.0.0. This version identifier corresponds to the <version> tag under <project> in the pom.xml file, which is in the SDK's project folder.

      • For Source Code License Text, type the license text of your source code, if any.

    2. For Android, specify the following:

      • For Group ID, type the unique identifier for the corresponding project. This is used in the pom.xml file (for example, com.mycompany).

      • For Invoker package, type the namespace for the generated client classes (for example, com.mycompany.clientsdk).

      • For Artifact ID, type the name of the compiled .jar file without the version. This is used in the pom.xml file (for example, aws-apigateway-api-sdk).

      • For Artifact version, type the artifact version number for the generated client. This is used in the pom.xml file and should follow a major.minor.patch pattern (for example, 1.0.0).

    3. For iOS (Objective-C) or iOS (Swift), type a unique prefix in the Prefix box. The effect of prefix is as follows: if you assign, for example, SIMPLE_CALC as the prefix for the SDK of the SimpleCalc API with Input, Output, and Result models, the generated SDK will contain the SIMPLE_CALCSimpleCalcClient class that encapsulates the API, including the method requests/responses. In addition, the generated SDK will contain the SIMPLE_CALCInput, SIMPLE_CALCOutput, and SIMPLE_CALCResult classes to represent the input, output, and results, respectively, to represent the request input and response output. For more information, see Use iOS SDK Generated by API Gateway in Objective-C or Swift.

  5. Choose Generate SDK, and then follow the on-screen directions to download the SDK generated by API Gateway.

  6. Do one of the following:

After updating an API, you must redeploy the API and regenerate the SDK to have the updates included.

Next, we show how to use the generated SDK to call the underlying API. To put the discussions in context, we will make reference the following example API and its SDKs.