API Management - Hands-on Lab Script - part 3

API Management

An API represents a set of operations that can be invoked. New APIs are defined and then the desired operations are added. An API is added to a product and can be published; it may then be subscribed to and used by developers.

APIs

On the left menu, open the [APIs] blade. You will see all APIs, the possibility to add new ones but also to customize existing ones

Add API from scratch

Instead of coding an API, for this lab you will use the existing Star Wars API https://swapi.dev.

Once created, select [Start Wars API]

Lets declare two operations

Switch now to the Developer Portal

Examine Response and more detailed Trace information

Import API using swagger

Instead of importing operations one by one, you can also import a full API. The OpenAPI specification (aka Swagger) is a definition format to describe RESTful APIs. The specification creates a RESTful interface for easily developing and consuming an API by effectively mapping all the resources and operations associated with it.

As a demo we will use an API that offers a simple calculator service : Calc API

Go to APIs blade and select [Add OpenAPI Specification]

We can inspect / edit the Open API definition by selecting the Edit icon from the Frontend block:

Let’s use another example - the Colors API

The swagger file did not contain the name of the host so you need to update it manually

We can test this from the [Test] tab

Switch to the Developer portal and look at Color API

Rate limit

Use Colors website which displays 500 lights. Each light will at random intervals make a call to the RandomColor API - and then display the color returned.

First we will need to enable CORS for the domain name of the frontend. To achieve this we have to do the following:

Here we will se this form, where we can add the domain name of our frontend https://markcolorweb.azurewebsites.net or the * for all domains:

Via the menu - there is a configuration page to specify the API endpoint

Open Developer portal, go in the Profile page and get API keys for Starter and Unlimited products


Home | Prev | Next