Software Development Kits (SDKs) contain the necessary toolkits to create an application using the OS to call the local API. If an API consumer wants to create an application, they can generate a server stub or client side SDK for a supported language/framework and use it to write a software application to consume the subscribed APIs.
Generating client SDKs in the API Store
By default, SDK generation is enabled for Java and Android. If those two languages are sufficient, move to step 3. To enable SDK generation for other languages,
<APIM_Home>/repository/conf/api-mamanger.xmlfile and edit the
<SupportedLanguages>property of the
<SwaggerCodegen>element to include any of the supported languages/frameworks. An example is shown below,
In this example, the supported languages are defined as Java, Android, Ruby and PHP.
- Once the above configuration is saved, start the API Manager server.
- In the API Store, open the API and click the SDKs tab. Download options are available for each programming language specified earlier in the
Download the SDK for the preferred language and use it to write software applications to consume the API.Tip: As mentioned above, a valid subscription should exist for the API. The SDK cannot be used without a valid access token for the subscription.
Generating server stubs and client SDKs in the API Publisher
The API Publisher has an embedded swagger editor with the ability to generate server code and client SDKs then and there.
Client SDK and Server Stub generation in API Publisher is only supported for Rest APIs.
- Open an existing API and choose to edit it.
- Click Edit Source to open the embedded swagger editor.
- To generate and download a server stub, click Generate Server and select a server stub from the list.
API deveopers can use the Generate Server option to generate the REST API structure based on the swagger definition. The actual backend implementation can be developed on top of the code generated using swagger code generator. You can select from a list of frameworks to generate the actual backend implementation stub of the REST API.
- To generate and download a client SDK, click Generate Client and select a client from the list.
The generated server stubs and client SDKs are generated using Swagger Codegen.
It is recommended to add the
securityDefinitions in the swagger definition to be able to pass access tokens when invoking an API. Edit the source of the API from the API Publisher and add the code given below.