Oracle by Example brandingConsuming an API in Oracle API Platform Cloud Service Developer Portal

section 0Before You Begin

This 10-minute tutorial shows you how to consume a published API using Oracle API Platform Cloud Service Developer Portal.

Background

Oracle API Platform Cloud Service Developer Portal is a simple catalog that provides information about published APIs. For an application to access an API, the application must subscribe to a plan that provides entitlement to the API.

In this tutorial, you are an application developer working for NextGen company. You have been tasked with creating an application for mobile devices that will allow customers to submit warranty claims. You want this application to invoke the Warranty Claim API. To accomplish this, you create an application in the Developer Portal and subscribe to a plan that allows your application to use the API.

What Do You Need?

  • Access to an Oracle API Platform Cloud Service Developer Portal instance with the Application Developer role.
  • Access to the published Warranty Claim API with a key validation policy.
  • URL of the gateway where Warranty Claim API is deployed.
  • Access to the published LifeTime Protection Plan.
  • A REST client tool

section 1Create an Application

Begin with creating an application. You can enter a name, description, and contact details for your new application.

  1. Sign in to Oracle API Platform Cloud Developer Service Portal as an application developer using the following URL format.

    https://instance-identitydomain.apiplatform.ocp.oraclecloud.com/developers

    Where, instance-identitydomain refers to the identity domain of your Oracle API Platform Cloud Service instance. For example:

    https://apidemo-paasproducm.apiplatform.ocp.oraclecloud.com/developers
  2. In API Platform Cloud Service Developer Portal, click My Applications.
  3. On the My Applications page, click Register Application.
  4. Enter the following values on the Register Application page.
    • Application Name: NextGen Mobile Claims
    • Description: Warranty Claim to protect your mobile device against any manufacturing defect.
    • Application Types: Mobile-iOS
    • First Name: John
    • Last Name: Doe
    • Email: john.doe@example.com
    Register Application page.
    Description of the illustration registerapplication.png
  5. Click Save.

    The My Applications page displays the newly created application, NextGen Mobile Claims.

  6. Click NextGen Mobile Claims to view the details. Note a unique application key is assigned to your application.
    Application page
    Description of the illustration application-view.png

    Use the application key in a header or as a query parameter to invoke a request for your API.


section 2Discover Your API in the Catalog

Next, find the desired API and evaluate the plan associated with it. In this tutorial, use the Warranty Claim API.

  1. In API Platform Cloud Service Developer Portal, click APIs.
  2. On the APIs page, enter Warranty Claim in the search box and click Search Search icon .
  3. Click the Warranty Claim API to open the API page.
    apicatalogpage
    Description of the illustration apicatalogpage.png
  4. On the Warranty Claim API page, click Plans Plans icon to view the associated plans that provide access to the API and click View Plan Details for the individual plans to view the plan details.
    This image shows the Plans page.
    Description of the illustration planspage.png

section 3Subscribe to a Plan for the API

Subscribe to a plan to enable your application to use the selected API. In this tutorial, subscribe to the LifeTime Protection plan.

  1. On the Warranty Claim API Plans page, click Subscribe.
  2. From the list of available plans, select Plan LifeTime Protection and click Select Plan.
    Subscribe API: Select Plan page.
    Description of the illustration selectplan.png
  3. From the list of available applications, select NextGen Mobile Claims and click Subscribe.
    Subscribe Application to API page.
    Description of the illustration selectapplication.png

    The subscription request is sent to Oracle API Platform Manager Portal. Your application users can consume the Warranty Claim API after the subscription is approved by Plan Manager.


section 3Invoke the Subscribed API from Your Application

After your subscription request is approved, invoke the API using the application key.

  1. Using the REST client tool, send the request to invoke the API. Use the application key in the header.

    The following example shows how to send a GET request with an application key in the header.

    curl -X GET 
      -H 'Accept: application/json' 
      -H 'Content-Type: application/json'
      -H 'appkey: 0ede-541dbfbf430d'
      http://example.com/warrantyclaim/1/tickets
    

    Where, example.com refers to the path of the gateway where API is deployed,warrantyclaim refers to your API and tickets refers to the REST resource.

  2. Review the response retrieved for the GET request.

section 4View Analytics for Your Application

Use analytics to determine the performance of the subscribed API on your application. You can review details such as how often and why requests to the API are rejected and what are the data trend, including the volume of request.

  1. On the API Developer Portal page, click My Applications.
  2. On the Application page, click NextGen Mobile Claims to open the application.
  3. Click Analytics Analytics icon .
  4. From the API drop-down list, select the Warranty Claim API.
    Analytics page.
    Description of the illustration application-analytics-api.png
  5. Click General or Errors and Rejections to view the available charts. The following example shows the volume of the request sent.
    Analytics page with a graph for Request Volume.
    Description of the illustration application-analytics-graph.png

section 5Unsubscribe from a Plan

You can unsubscribe an application from a plan if you no longer want your application users to have access to the APIs entitled by the plan.

  1. On the NextGen Mobile Claims page, click Subscriptions Subscriptions icon.
  2. From the list of available plans, click LifeTime Protection and click Unsubscribe.
    Subscriptions page for an application.
    Description of the illustration unsubscribe.png
  3. In the Warning dialog, click Yes to confirm.

    The subscription to the plan is now removed. You can re-subscribe to the plan if you want to access its APIs.

more informationWant to Learn More?