This documentation is for WSO2 API Manager 2.0.0 View documentation for the latest release.
Page Comparison - Quick Start Guide (v.25 vs v.26) - API Manager 2.0.0 - WSO2 Documentation

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: https://wso2.org/jira/browse/DOCUMENTATION-4533

...

  1. Open the API Publisher (https://<hostname>:9443/publisher) and sign in with admin/admin credentialscredentials.
  2. Click the Deploy Sample API button. It deploys a sample API called PizzaShackAPI into the API Manager.

  3. Click PizzaShackAPI to open it. 

    Let's publish this API.

  4. Go to the Lifecycle tab and note that the State is PUBLISHED. The API is already published to the API Store.

  5. Sign in to the API Store (https://<hostname>:9443/store) with the admin/admin credentials and click on the PizzaShackAPI API.

  6. Select the default application and an available tier, and click Subscribe.

  7. When the subscription is successful, click View Subscriptions on the information message that appears. Click the Production Keys tab and click Generate Keys to generate an access token to invoke the API. 

    You have now successfully subscribed to an API. Let's invoke the API using the integrated Swagger-based API Console.

  8. Click the APIs menu again and click the PizzaShackAPI to open it. When the API opens, click its API Console tab.

    Expand the GET method (which retrieves the menu) and click Try it out

    Note the response for the API invocation. It returns the list of menu items.

...

Creating users and roles

In users and roles, we introduced a set of users who are commonly found in many enterprises. Let's see how you can sign in to the Management Console as an admin and create these roles.

  1. Sign in to the Management Console (https://<hostname>:9443/carbon) of the API Manager using admin/admin credentials.

  2. Click Add in the Users and Roles section under the Main menu.
  3. Click Add New Role. 
  4. Give the role name as creator and click Next.
  5. A list of permissions opens. Select the following and click Finish.
    • All Permissions > Admin Permissions > Configure > Governance and all underlying permissions
    • All Permissions > Admin Permissions > Login
    • All Permissions > Admin Permissions > Manage > API > Create  
    • All Permissions > Admin Permissions > Manage > Resources > Govern and all underlying permissions    

  6. Similarly, create the publisher role with the following permissions.

    • All Permissions > Admin Permissions > Login
    • All Permissions > Admin Permissions > Manage > API > Publish
  7. Note that the API Manager comes with the subscriber role available by default. It has the following permissions:

    • All Permissions > Admin Permissions > Login
    • All Permissions > Admin Permissions > Manage > API > Subscribe
  8. T he The roles you added (creator and publisher) are now displayed under Roles.

    Let's create users for each of the roles. 
  9. Click Add in the Users and Roles section under the  Main menu.
    Image Modified
  10. Click Add New User.
  11. Give the username/password and click Next. For example, let's create a new user by the name apipublisher.
  12. Select the role you want to assign to the user (e.g., publisher) and click Finish

  13. Similarly, create a new user by the name apicreator and assign the creator role.

...

  1. Sign in to the API Publisher (https://<hostname>:9443/publisher) as apicreator .
  2. In the APIS menu, click Add New API.
  3. Select the option to design a new API and click Start Creating .
    Image Modified

  4. Give the information in the table below.

    FieldSample value
    Name
    PhoneVerification
    Context
    /phoneverify
    Version1.0.0
    VisibilityPublic
    API Definition
    • URL pattern: CheckPhoneNumber  
    • Request types: GET, POST

    Click Add and then click Next:  Implement > to move on to the next page.

  5. Select the Managed API option.

  6. Give the following information and click Next:M anage > once you are done.

    FieldSample value
    Endpoint typeHTTP/REST Endpoint
    Production endpoint

    In this guide, we work with a service exposed by the Cdyne services provider. We use their phone validation service, which has SOAP and REST interfaces. Endpoint is http://ws.cdyne.com/phoneverify/phoneverify.asmx. To verify the URL, click the Test button next to it.

    This sample service has two operations: CheckPhoneNumber and CheckPhoneNumbers. Let's use CheckPhoneNumber here.

    Sandbox endpointEndpoint is http://ws.cdyne.com/phoneverify/phoneverify.asmx. To verify the URL, click the Test button next to it.

  7. Provide the following information in the Manage tab. Leave default values for the rest of the parameters in the UI.

    FieldValueDescription
    Subscription Tiers<Select all available tiers>The API can be available for subscription at different levels of service. They allow you to limit the number of successful hits to an API during a given period of time.

  8. Once you are done, click Save

...

  1. In the APIS menu, click the thumbnail of the API to open it. 

  2. Click on the API's Docs tab and click Add New Document.

  3. The document options appear. Note that you can create documentation inline, via a URL, or as a file. For inline documentation, you can edit the content directly from the API publisher interface. You get several documents types:

    • How To
    • Samples and SDK
    • Public forum / Support forum (external link only)
    • API message formats
    • Other
  4. Create a 'How To' named PhoneVerification, specifying in-line content as the source and optionally entering a summary. When you have finished, click Add Document.
    Image Modified

  5. Once the document is added, click Edit Content to open an embedded editor.

  6. Enter your API's documentation and click Save and Close.

Adding interactive documentation

WSO2 API Manager has an integrated Swagger UI , which is part of the Swagger project. 

Swagger is a 100% open source, standard, language language-agnostic specification agnostic specification and a complete framework for describing, producing, consuming, and visualizing RESTful APIs, without the need of a  proxy or third-party services . Swagger allows consumers to understand the capabilities of a remote service without accessing its source code and interact with the service with a minimal amount of implementation logic. Swagger helps describe a services in the same way that interfaces describe lower-level programming code. 

The Swagger UI is a dependency-free collection of HTML, JavaScript, and CSS that dynamically generates documentation from a Swagger-compliant API. Swagger Swagger-compliant APIs give you interactive documentation and more discoverability.  The Swagger UI has JSON code, and its UI facilitates easier code indentation, provides keyword highlighting, and shows syntax errors on the fly. You can add resource parameters, summaries and descriptions to your APIs using the Swagger UI.

Also, see the the  Swagger 2.0 specification.

  1. Open the API Publisher (https://<hostname>:9443/publisher) and sign in as apicreator.
  2. Click the Edit icon for the PhoneVerification API. This opens the API in its edit mode.
  3. Click the Edit Source button under the API Definition section.
  4. Anchor
    this step
    this step
    The JSON code of the API opens in a separate page. Expand its GET method, add the following parameters and click Apply Changes.
    Anchor
    this step
    this step

    Code Block
    parameters:
            - in: query
              name: PhoneNumber
              description: Give the phone number to be validated
              type: string
              required: true
            - in: query
              name: LicenseKey
              description: Give the license key as 0 for testing purpose
              type: string
              required: true

  5. Back in the API Publisher, note that the changes you did appear in the API Console's UI. You can add more parameters and edit the summary/descriptions using the API Publisher UI as well. Once done, click Save.

...

  1. Go to the API Store (https://<hostname>:9443/store) and create an account using the Sign-up link.

  2. After signing up, sign in to the API Store and click the PhoneVerification 2.0.0 API that you published earlier.

  3. Note that you can now see the subscription options. Select the default application and the Bronze tier. Click Subscribe.

  4. Once the subscription is successful, click View Subscriptions in the information message that appears to review your subscriptions.
  5. Click the Production Keys tab of the application and then click Generate Keys to generate an access token that you use later to invoke the API. If you have already generated keys before, click Re-generate.

    Tip

    Tip : You can set a token validity period in the given text box. By default, it is set to one hour. If you set a minus value (e.g., -1), the token will never expire.

You are now successfully subscribed to an API. Let's invoke it.

...

Both the API publisher and store provide several statistical dashboards.
 
API Publisher statistics

 

API Store statistics

 

The steps below explain how to configure WSO2 API Manager Analytics with the API Manager. The statistics in these dashboards are based on data from WSO2 Data Analytics Server (DAS). 

Let's do the configurations first.

Tip

Before you begin

  1. Download the WSO2 APIM Analytics distribution by clicking ANALYTICS in the WSO2 API Management page. It is best to download and extract it to the same directory to which you downloaded WSO2 API Manager.
  2. If you have the API Manager server running, stop the server.
  3. If you are running on Windows, download download the snappy-java_1.1.1.7.jar from here and copy the JAR file to the <ANALYTICS_HOME>\repository\components\lib  directory.
  1. To enable Analytics, open the <APIM_HOME>/repository/conf/api-manager.xml file and set the Enabled property under Anaytics to true as shown below. Save this change.

    Code Block
    languagexml
    <Enabled>true</Enabled>
  2. Open the <APIM_HOME>/repository/conf/log4j.properties file. Add DAS_AGENT to the end of the log4j.rootLogger property   property as shown in the example below.

    Code Block
    log4j.rootLogger=ERROR, CARBON_CONSOLE, CARBON_LOGFILE, CARBON_MEMORY, CARBON_SYS_LOG, ERROR_LOGFILE, DAS_AGENT
  3. Start the WSO2 APIM Analytics server, and then start the API Manager server. To start a WSO2 product server, navigate to the <PRODUCT_HOME>/bin directory in your console and run one of the following scripts as relevant.
    1. On Windows:  wso2server.bat --run
    2. On Linux/Mac OS:  sh wso2server.sh

  4. Invoke several APIs to generate some statistical data and wait a few seconds. 
  5. Connect to the API Publisher as a creator and click one of the statistical dashboards available in the Statistics menu. For example, 

...