Technology Blogs by SAP
Learn how to extend and personalize SAP applications. Follow the SAP technology blog for insights into SAP BTP, ABAP, SAP Analytics Cloud, SAP HANA, and more.
Showing results for 
Search instead for 
Did you mean: 

Today we are excited to announce the launch of an exciting addition to the support space for SAP HCP, API Management, a Public GitHub repository of sample API Proxies and Applications to showcase some of the capabilities SAP HCP, API Management offers, in a quick and easy to consume manner.

For those familiar with GitHub, you may simply want the URL to run with, but for those less familiar, I will be providing a simple walk through on the simple method of grabbing a sample API Proxy and importing into your own environment. This walk-through will follow the Trial account, but the process will be the same for Productive customers as well.

Getting Access

The GitHub can be found here: SAP Public GitHub - SAP HCP, API Management API Proxies

Getting Started


Once you are on the GitHub Page you can either navigate directly through the code (if you are familiar with GitHub):

Or for those wanting a little explanation of what samples are available first, scroll down the homepage for a documented samples list.
For this walk through we will select the Spike Arrest policy sample. As the documentation tells us, this is a type of Throttling policy, which will restrict how quickly requests can be made against an API Proxy.

Simply click the name to open the related folder.

As before you will be presented with multiple ways to consume the API Proxy, either from the direct listing, or from the documentation area. Additionally you will see documentation explaining the what the Policy is intended to do, the code it contains, and how the code works, as well as a link to more in-depth documentation specific to the policy type.

Once finished reading, click on either Zip file to access the Sample download.

This will bring you to the download page. Click either "View Raw" or "Download" button to save the sample. Make sure to keep track of where the file downloads, as you will need this to import later.

Importing the Sample into API Management

Once the download completes, access your HCP Trial API Management account. ( HCP Trial Account  -> Services tab under -> Integration category -> SAP API Management)

This will bring you to the Home screen of SAP API Management Administrator Portal. Click the three horizontal bars in the top left hand corner to expand the Navigation Menu then select "Manage" to open the APIs list.

In the list of available APIs click the "Import API" button. This will bring up the Import API Wizard. Click Browse to navigate to where you saved the Spike Arrest .zip file saved in the previous section.

With this, the API Proxy should now appear on your list of APIs, already deployed, and replete with Documentation. Select the API Proxy name (SpikeArrest) to enter the API Proxy for access URL and details.

This will open the details of the API Proxy, including the API Proxy URL, used to connect to the API Proxy, the Target Endpoint details, which provides the data, description/documentation and more. Before actually hitting the API Proxy, let's look at the pre-configured Policies that make it possible. Click the "Policies" button.

This will enter the Policy Editor screen, which you can use to Add/Edit/Delete policies on an API Proxy. For this sample proxy, there will be only one policy added, the SpikeArrest Policy. To view it, on the far left select "Preflow" under "Proxy EndPoint" and then click the "spikearrest" icon in the Incoming Request flow.

Note the simple code is currently configured for Rate of 2pm. This means an average of 2 requests per minute. Refer to documentation for more on the available options.

Now to test the API Proxy, and see this policy in action, click the left arrow <- in the corner to return to the API Proxy screen. In this screen, copy the API Proxy URL. Open a new Browser Tab and paste the URL there to access.  Then refresh the page 2 more times, on the 3rd try you should receive an error from the Spike Arrest policy saying you are attempting to access the Proxy too quickly.

Here you will need to provide your ES4 credentials (if you do not have them, use the link at the top to sign up).

Refresh the page 2 more times.

On the 3rd try you should receive an error from the Spike Arrest policy saying you are attempting to access the Proxy too quickly

So with only a few clicks you have successfully pulled a working API Proxy into your landscape! Remember you can also go back into the Policy and edit the code, to try out changing the sample code as well (and if you mess anything up too badly, you can just delete it and re-import the sample code).

Wrap Up

With this, we hope that you can see the utility of using the API Proxy sample repository. Example policies, sample code, documentation, and a working, configurable proxy to understand more quickly how to utilize SAP API Management with your systems.
I recommend this as a starting point to quickly view API Proxies in action, then apply what you learn to creating your own API Proxies.

The intention is to continue to provide more and expanded content via GitHub in a flexible manner, so please continue to check the repository. You may also provide suggestions about content that would be helpful to understanding API Management usage on the community, or via E-Mail.

For additional information: SAP API Management - Overview & Getting started