WSO2 API Cloud documentation is getting a whole new look at
Try WSO2 Cloud for Free
Sign in

All docs This doc
Skip to end of metadata
Go to start of metadata

A prototype is an early implementation of an API that you create with an inline script and then make available for testing purpose and to collect feedback from subscribers while you work on a proper, long-term implementation.

In this tutorial, you create an API prototype with an inline JavaScript code, deploy it and invoke it using the API Console integrated in the API Store. 

Let's get started. See the video tutorial here or a step-by-step walk-through of the video tutorial below.

Here's a step-by-step walk-though of the video tutorial:

  1. Log in to the API Publisher.
  2. Select the option to design a new API and click Start Creating.
  3. In the page that opens, enter the information given in the table below. To add resources, click the Add button.

    • URL pattern: CheckPhoneNumber/{PhoneNumber}
    • Request types: GET

  4. Once the information is added, click Implement to go to the next page.

  5. As this is a prototyped API, you do not have an actual backend implementation for it yet. Therefore, in the Prototype sections under the Implement tab, click the implementation method as Inline.
    The default skeleton code generated by the API Cloud reads the PhoneNumber parameter value from the URL and give it as a JSON output.  

  6. Expand the GET method. The default skeleton code generated by the API Cloud reads the PhoneNumber parameter value from the URL and give it as a JSON output. Replace the skeleton code with the following, which produces a realistic XML output that your actual implementation will someday provide.

    var PhoneNumber = mc.getProperty('uri.var.PhoneNumber');
          "Company":"Toll Free",
          "Use":"Assigned to a code holder for normal use.",
          "Country":"United States",

  7. Click the Deploy as a Prototype button at the end of the page to deploy the prototype.

  8. When prompted, click the Go to API Store button. 

  9. The API opens in the API Store. Note that its status is PROTOTYPED.

    Let's invoke the API prototype.

    Tip: You can invoke prototyped APIs without signing in to the API Store or subscribing to the API. The purpose of a prototype is advertising and giving an early implementation for users to test.

  10. Go to the API's API Console tab, expand the GET method, give any value for the parameter (say phone number is 18006785432) and click Try it out.

  11. Note the response you get according to the XML pattern you defined in step 6.

You have created an API with inline script, deployed it as a prototype and invoked it through the integrated API Console.

  • No labels