Generate SDKs for an API using AWS CLI commands in API Gateway - Amazon API Gateway

Generate SDKs for an API using AWS CLI commands in API Gateway

You can use AWS CLI to generate and download an SDK of an API for a supported platform by calling the get-sdk command. We demonstrate this for some of the supported platforms in the following.

Generate and download the Java for Android SDK using the AWS CLI

To generate and download a Java for Android SDK generated by API Gateway of an API (udpuvvzbkc) at a given stage (test), call the command as follows:

aws apigateway get-sdk \ --rest-api-id udpuvvzbkc \ --stage-name test \ --sdk-type android \ --parameters groupId='com.mycompany',\ invokerPackage='com.mycompany.myApiSdk',\ artifactId='myApiSdk',\ artifactVersion='0.0.1' \ ~/apps/myApi/myApi-android-sdk.zip

The last input of ~/apps/myApi/myApi-android-sdk.zip is the path to the downloaded SDK file named myApi-android-sdk.zip.

Generate and download the JavaScript SDK using the AWS CLI

To generate and download a JavaScript SDK generated by API Gateway of an API (udpuvvzbkc) at a given stage (test), call the command as follows:

aws apigateway get-sdk \ --rest-api-id udpuvvzbkc \ --stage-name test \ --sdk-type javascript \ ~/apps/myApi/myApi-js-sdk.zip

The last input of ~/apps/myApi/myApi-js-sdk.zip is the path to the downloaded SDK file named myApi-js-sdk.zip.

Generate and download the Ruby SDK using the AWS CLI

To generate and download a Ruby SDK of an API (udpuvvzbkc) at a given stage (test), call the command as follows:

aws apigateway get-sdk \ --rest-api-id udpuvvzbkc \ --stage-name test \ --sdk-type ruby \ --parameters service.name=myApiRubySdk,ruby.gem-name=myApi,ruby.gem-version=0.01 \ ~/apps/myApi/myApi-ruby-sdk.zip

The last input of ~/apps/myApi/myApi-ruby-sdk.zip is the path to the downloaded SDK file named myApi-ruby-sdk.zip.

Next, we show how to use the generated SDK to call the underlying API. For more information, see Invoke REST APIs in API Gateway.