Creating an API

Objective

After completing this lesson, you will be able to Create an API based on the API provider.

Creation of APIs Based on the API Provider

In this lesson, the following topics are discussed:

  • What are the possibilities to create an API?
  • Create an API using Create button.
  • Create an API using menu links.

What are the Possibilities to Create an API?

The API which will be created is important for the further implementations. It acts as a proxy of the actual resource API. The previous name was API Proxy. This name often appears in older documentaries.

The following options are available:

Create an API using the Create button with the following options:
  • API provider (No. 1 at concept diagram)
  • URL (No. 2 at concept diagram)
  • API proxy
Create an API using menu links with the following options
  • Create in API Designer (No. 3 at concept diagram)
  • Import an external API

Create an API Using the Create Button

This is probably the most common case. With this option, you are able to create an API with an API provider, an provided URL or an existing API.

Procedure

  • Start with DesignAPIs to open the Develop screen.
  • Start the wizard by choosing the Create button. A new window opens.

Use the API Provider option.

Select the API Provider radio button and open the select box. All API providers display. Choose one, for example: SAPGatewayDemoSystemES5_Provider.

When the API Provider is chosen, a new list box with the name, Discover, is available. Some data, such as the host and the type of API, have already been entered.

When the list box is chosen, all available services listed within the catalog service, are displayed.

What exactly is displayed here depends on the type of API Provider. In the case of Open Connectors, for example, all instances are displayed. For the type Cloud Integration, the available integration flows.

The following figure shows a list of available services which are usable from the SAP backend system. The API provider gets defined by choosing one service from the provided catalog services.

You can choose exactly one of the offered services. After that, further data is added to the mask.

When you finish creating this API (Proxy), it has to be deployed so that it can be used. After that, the API (proxy) is ready for testing. The service type is automatically defined. In this case, it is OData.

Use the URL option to create an API

In case you do not use an API provider, you can directly specify the URL of your source.

In this case, you must enter the data manually (marked). The Service Type can only be REST or SOAP.

After saving and deploying the API, it can also be tested.

Use the API Proxy option to create an API

In this case, you can copy an existing API.

In this case, you must enter the data manually (marked). The Service Type can only be REST or SOAP, even if the spied API is from type OData.

Create an API Using Menu Links

Use the Create in API Designer option

Start creating an API by choosing the menu link, Create in API Designer.

Switch to the openAPI editor and can manually create your API there through the openAPI language in YAML. In this case, all entries must be created manually. The server URL is automatically adjusted after saving. The Service Type can only be REST.

Before saving

After saving

Note

Be aware that the shown URL is a sample and will not work.

Import an external API

Start the creation of an API by choosing the menu link, Import API.

The Service Type corresponds to the imported API.

Resource

Help Portal: Create an API Proxy

Summary

There are several ways to create an API. API`s can be created:

  • By using the Create button.
  • Based on an existing API provider
  • directly through an provided URL.

At last you can define it also with an openAPI specification via the Create button in API Designer.

Create an API Based on a pre-Defined API Provider

Business Scenario

We want to connect the API provider to a new API that we create in API Management. The connection and artifacts we create is shown in blue in the component diagram.

Task Flow

In this exercise, you will perform the following tasks:

  1. Create an API.
  2. Test the API.

Prerequisites

  • You have a working API Management.
  • You have an API Provider based on the SAP Gateway Demo system ES5.

Outcome After This Exercise

Has a working API based on the API Provider from ES5 demo system. This allows APIs to be called from the ES5 demo system.

What Do You Learn Within This Exercise

Can create an API based on an API Provider from type internet. Can call APIs from ES5 demo system.

Exercise Options

To carry out this exercise, you can choose from the following options:

  1. Live Environment: Using the instructions provided below, you can perform the steps in your SAP BTP account.
  2. Platform Simulation: Follow the step-by-step instructions within the simulation.
  3. Side-by-side: Follow the step-by-step instructions within the simulation and perform the steps in your SAP BTP account simultaneously.

Note

We strongly recommend to perform the steps in the live environment.

Task 1: Create an API

Steps

  1. Create an API based on an API Provider.

    1. Navigate to ConfigureAPIs.

    2. Choose the Create button.

    3. In the API Provider field, choose your SAPGatewayDemoSystemES5_Provider.

    4. Since we are now calling the catalog data from the ES5 system, we have to choose a concrete API. Choose the Discover button that is available after selecting the API Provider.

    5. After choosing the Discover button, a new pop-up window opens and the available interfaces on the ES5 system display.

    6. Here we select GWSAMPLE_BASIC.

    7. Choose OK.

    8. You get back to the first pop-up window and the most fields are pre-filled with data.

  2. Enter a version.

    1. Enter v1 into the Version field. The v1 is immediately appended as a prefix in the Name field and as a path postfix in the API Base Path field.

    2. Choose the Create button.

    3. In the new window, choose the Save button, if you still want to work later on this task. It is also possible to choose directly the Deploy button, if you have entered all parameters.

  3. Deploy your API.

    1. After saving your API, you have to deploy it.

    2. Navigate back to the Develop view of your API. Use the ActionDeploy button at your API.

    3. If your API is deployed, you will see the Status as Deployed.

  4. Explore Resources View API.

    1. Navigate to the Develop view of your APIs. Choose your API GWSAMPLE_BASIC_v1.

    2. Choose the Resources tab.

    3. You will find the openAPI standard client based on your OData API from the ES5 system.

    4. Choose the first entry, GET /BusinessPartnerSet.

    5. Choose the Try out button.

      A new Execute button appears a little further down.

    6. Choose the Execute button.

    7. You will get an HTTP code 401 - Unauthorized. The user and password in the API provider is only used to create the API provider but not for the actual call of the API.

  5. Explore the API Designer.

    1. The open API client based on a specification according to openAPI 3.0. This is written in yaml or JSON.

    2. Open Edit and choose Edit in API Designer to open the open API specification.

    3. In the API Designer you are able to adjust all OpenAPI specifications by yourself.

    4. Based on this open API editor you can design API’s from scratch.

Task 2: Test the API

Steps

  1. Test your API.

    1. Your API is deployed but not accessible directly through the openAPI client due to a lack of authorization to the ES5 interface.

    2. Navigate to TestAPIs.

    3. Choose your API from the left side, for example, GWSAMPLE_BASIC_v1.

    4. In the address navigation menu /ProductSet on the end of the path. The GET method is automatically selected.

    5. Choose the link, Authentication:None, above the address bar. Choose Basic Authentication.

    6. Fill in the ES5 user and password and choose the OK button.

    7. Now, choose the Send button on the bottom right of the screen.

    8. If you get an HTTP status code 200, everything works as expected.

Log in to track your progress & complete quizzes