How to use SAP API Hub (Beta)

As you might have seen right now the content in the SAP API Hub (Beta) is quite limited but over time we will add more and more. In order to show you how you can work with the content offered I want to go through one example using a service from the SAP Translation Hub.

When you access your SAP HCP Trial instance and go to Services you will see one new entry: the SAP API Hub.

How to use SAP API Hub (Beta)

By default it is already enabled so if you click on it you can find the usual description and the URL to access it.

How to use SAP API Hub (Beta)

Once you do that you will see all the content that is currently available via the Hub:

How to use SAP API Hub (Beta)

As mentioned the content is quite limited right now, but we are in Beta and working with different teams within SAP to get more and more content over time. For now let’s click on the SAP Translation Hub API Icon, which will provide more information on the available APIs. The package that contains the APIs is called a Product. So in our case the “SAP Translation Hub API” is a product that contains APIs which allow you to leverage translation services.

How to use SAP API Hub (Beta)

Usually you would first take a closer look at the APIs which are part of this Product, but since we already know that we want to use services out of the SAP Translation Hub API, lets immediately subscribe to this Product. This will later allow us to consume the services using an API Key.
So in the lower right corner click on Subscribe and select “New Application” — which means that we want to use the APIs belonging to this Product in our Application.

How to use SAP API Hub (Beta)

As a next step we need to provide a name and description for our new application:

How to use SAP API Hub (Beta)

With that we can finally take a closer look at the available APIs (again, this is something that you would usually do upfront – now we just want to take a closer look at some of the features that the SAP API Hub Beta has to offer):

How to use SAP API Hub (Beta)

The overview page provides some generic information. What is this product used for, how can you access the product (the API Proxy URL) and it lists the available services (the “Resources”). When you click on the Details you can get more information. In our case you get some information with Simple Examples on how you can use these services.

How to use SAP API Hub (Beta)

As you can see one of the variables that we need to provide in order to use the services is the API Key. Since we already have subscribed to the Product, we already access this API Key.
So lets switch from the current Discovery mode, to the Consumption Mode.

How to use SAP API Hub (Beta)

From here we can see all the Applications that we have created. As of now it is only our TranslationHub application that we created when we subscribed to the SAP Translation Hub product before. Lets click on this application:

How to use SAP API Hub (Beta)

Now we can see the Application Key which we need to call this specific API. Copy this value so that we can use it later.

How to use SAP API Hub (Beta)

We will use the Translate service from the Translation Service. Lets take a closer look at what this service has to offer. Click on the SAP Translation Hub Services and expand the Translate Section:

How to use SAP API Hub (Beta)

You can see the URL, see that it is a POST call and also some other information.
Usually we would now continue to go to the Test Section and test the API.

How to use SAP API Hub (Beta)

Unfortunately (remember, we are still in Beta). Test is not working (we have a certificate mismatch…) so we will need a different tool. I am use the Google Chrome Add-in Postman.
In Postman, select POST, enter the URL

https://apihub.hanatrial.ondemand.com/translationhub/api/v1/translate

and go to the Headers section. From there add the fields

Header Value
Content-Type application/json
APIKey   <Paste the API Key value from before>

How to use SAP API Hub (Beta)

As a last step switch to the Body tab and copy the required content (usually you would get this information from the Description of the individual API).

{ “targetLanguages” : [“en”, “de”, “fr”, “bg”, “ru”], “bundles” : [{ “units” : [{“textType” : “XFLD”, “value” : “Password” }]}]
}
Once that is done click on Send.

How to use SAP API Hub (Beta)

As a result you get the translation of the word Password in different languages (I can only verify that the translation of Password to German is “Kennwort” — so great!

Leave a Reply

Your email address will not be published. Required fields are marked *