As software developers for Health, after subscribing to one of the APIs of our Marketplace for Health, we will need to test the APIs to which we have subscribed before integrating them into our application. The Nubentos platform provides the API Store with the possibility to test each of the resources that make up the API.
In this Howto we will show the steps to follow.
Tabla de Contenidos
What you will learn
In this tutorial, you will learn how to:
- Create an Application to subscribe and do the tests.
- Perform a simple test of an API resource.
What you need to test your API
To follow this tutorial, you must have your account credentials for the Nubentos Store. To obtain your user account you must register using the corresponding option that you will find in the upper right corner of the API Store.
In this how-to we will use a test API called “MedicalAPI”. Throughout the article, when we refer to this API you can apply the steps to the API that you are using.
Create an Application for tests
The first step is to create an application where we will add the subscriptions to the APIs of our interest. This will allow us to establish the limits of use and to be able to generate the necessary security tokens to be able to consume the APIs.
The steps to create the application are the following:
- We access the Nubentos API Store, where we will locate the API we want to use and we will access its Publisher’s Store through the Visit PublisherStore button.
- Once in the API Store of the API provider, we will enter the login credentials and click on Sign In.
- Remember that in this how-to we will use a test API called “MedicalAPI”. In your case you can follow these steps with another API of your interest.
- In the menu on the left we select “Applications“. By default we will see a single application called “DefaultApplication”.
- We will create a new application by clicking on the “ADD APPLICATION” button, at the top menu.
-
Fill in the data and click on the “Add” button:
- Name: Name that we will give to our application, for example “TestAPP”.
- Per Token Quota: Limit of requests, since we are going to perform a simple test we will indicate “10PerMin”. This will help us control the consumption of the plan to which we are going to subscribe.
- Description: We will indicate the use that we are going to give to this application, eg. “This app is used to test MedicalAPI”.
- In the menu of our application we can generate the keys for each environment and see the current subscriptions. We will generate the keys for the SandBox environment by clicking on the “Sandbox Keys” tab.
- In the lower part of this screen we can see the access token that we will use in the requests that we will send to the API, and its expiration time.
Now we can subscribe our APIs to this application and perform the test.
Perform a simple test of an API resource
- We click on APIS in the menu on the left and on the API icon “MedicalAPI”.
- In the right side we select the “TestAPP” application and in Tier we select the level that we want, and click on the “Subscribe” button.
- We see now a message indicating that we have subscribed correctly and invites us to view the subscription, but instead we will stay on the current page, by clicking on “Stay on this page“.
- On the API detail page, click on the “API Console” tab and we will test our “TestAPP” application with the “Sandbox” environment. Notice that the authorization token that we generated in a previous step automatically appears in its field.
- If we scroll down the page we will see the list of available resources. We will move to “/ pacient / {pacientname}” GET resource.
- Click on the GET resource and a section with the information related to this resource is displayed. Here we can identify in the upper right part a small description, in the central area the format of a correct answer with response code 200, and in the lower part other messages for each one of the controlled error codes.
- Fill in the fields to enter the name of the patient “pacientname” and click on the “Try it out” button at the bottom. The screen will be updated to show us certain commands and the result of our request.
- We may receive a code 401, and see an output similar to the following:
- In this case we must “Regenerate” the employee token since it is expired.
We must remember that we are using the “Sandbox” endpoint. The returned results will not be real data, they can even be self-generated data (as in our test API) with the sole purpose of being able to test the API.
This way, we have been able to verify the operation of one of the resources of the API. Now, we can go through the rest of the resources and fill in their parameters with the required data, to test them all.
Without leaving Nubentos API Store, we can learn about and understand the operation of the API with our API test console, before writing a single line of code in our software.
0 Comments