Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

WSO2 API Manager is a complete solution for publishing APIs, creating and managing a developer community and for routing API traffic in a scalable manner. It leverages the integration, security and governance components from the WSO2 Enterprise Service Bus, WSO2 Identity Server, and WSO2 Governance Registry. In addition, as it is powered by the WSO2 Business Activity Monitor (BAM), the WSO2 API Manager is ready for massively scalable deployments immediately.

...

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

  3. Click WeatherAPI 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. Log in to the API Store (https://<hostname>:9443/store) with admin/admin credentials and note that WeatherAPI is visible under the APIs menu. Click it to open the API.

  6. The subscription options are on the right-hand side of the page. Select the default application and an available tier, and click Subscribe.

  7. When the subscription is successful, choose to go to the My Subscriptions page and click the Generate keys button to generate an access token to invoke the API. 

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

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

  9. Expand the GET method, give the parameter value as "London," and click Try it out
  10. Note the response for the API invocation. It returns the weather in London.

...

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

  2. Select the Users and Roles menu under the Configure menu.
  3. Click the Roles link and then 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.
    • Configure > Governance and all underlying permissions
    • Login
    • Manage > API > Create  
    • Manage > Resources > Govern and all underlying permissions    

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

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

      • Login
      • Manage > API > Subscribe
  8. Note that the roles you added (creator, internal/subscriber, and publisher) are now displayed under Roles.
    Let's create users for each of the roles. 
  9. Click the Users and Roles menu under the Configure menu again.
  10. Click the Users link and then 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. After saving the API, click its thumbnail in the API Publisher to open it.

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

  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.

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

  6. Enter your API's documentation.

...

The steps below explain how to configure WSO2 Business Activity Monitor (BAM) 2.5.0 with the API Manager. The statistics in these dashboards are based on data from the BAM. The steps below explain how to configure WSO2 BAM 2.5.0 with the API Manager.

Tip

If you are on Windows, note the following:

  • If you installed the JDK in Program Files in the Windows environment, avoid the space by using PROGRA~1 when specifying environment variables for JAVA_HOME and PATH. Otherwise, the server throws an exception.
  • Install Cygwin (http://www.cygwin.com). WSO2 BAM depends on Apache Hadoop, which requires Cygwin in order to run on Windows. Install at least the basic net (OpenSSH,tcp_wrapper packages) and security-related Cygwin packages. After Cygwin installation, update the PATH variable with C:/cygwin/bin. If you already have WSO2 BAM running, you must restart it now.

Let's do the configurations first.

  1. Apply an offset of 3 to the default BAM port by editing the <BAM_HOME>/repository/conf/carbon.xml file. This makes the BAM server run on port 9446 instead of the default port 9443, and avoids port conflicts when multiple WSO2 products run on the same host.

    Code Block
    languagexml
    <Offset>3</Offset>
  2. Download MySQL from https://www.mysql.com/ and install it in your server.
  3. Go to the command-line and issue the following commands to connect to the MySQL server and create a database (e.g., TestStatsDB). This database is used to save the statistical data collected by the BAM. You do not need to create any tables in it.

    Code Block
    mysql -u <username> -p <password> -h <host_name or IP>;
    CREATE DATABASE TestStatsDB;
  4. Save the MySQL connector JAR inside both the <APIM_HOME>/repository/components/lib and <BAM_HOME>/repository/components/lib folders.

  5. Give the datasource definition under the <datasource> element in the <BAM_HOME>/repository/conf/datasources/master-datasources.xml file. For example,

    Code Block
    languagexml
    <datasource>
       <name>WSO2AM_STATS_DB</name>
       <description>The datasource used for getting statistics to API Manager</description>
       <jndiConfig>
           <name>jdbc/WSO2AM_STATS_DB</name>
       </jndiConfig>
       <definition type="RDBMS">
           <configuration>
               <url>jdbc:mysql://localhost:3306/TestStatsDB</url>
               <username>db_username</username>
               <password>db_password</password>
               <driverClassName>com.mysql.jdbc.Driver</driverClassName>
               <maxActive>50</maxActive>
               <maxWait>60000</maxWait>
               <testOnBorrow>true</testOnBorrow>
               <validationQuery>SELECT 1</validationQuery>
               <validationInterval>30000</validationInterval>
            </configuration>
       </definition>
    </datasource>
  6. Start the BAM server by running either of the following commands in the command line:

    • On Windows:  <PRODUCT_HOME>\bin\wso2server.bat --run
    • On Linux/Solaris/Mac OS:  sh <PRODUCT_HOME>/bin/wso2server.sh

  7. Start the API Manager and log in to its Admin Dashboard Web application (https://<Server Host>:9443/admin-dashboard) with admin/admin credentials.
  8. Click the Configure Analytics menu. 

  9. Select the  check box to enable statistical data publishing and add the following:

    • Add a URL group as tcp://<BAM server IP>:7614 and click Add URL Group.
    • Fill the details under Statistics Summary Database according to the information you added to the master-datasources.xml file in step 4.

  10. Click Save. The BAM deploys the Analytics toolbox, which describes the information collected, how to analyze the data, and the location of the database where the analyzed data is stored.

  11. Invoke several APIs to generate some statistical data and wait a few seconds. 

  12. Connect to the API Publisher as a creator or publisher and click the statistical dashboards available under the All Statistics and Statistics menus. For example,
    The All Statistics menu is available for both API creators and publishers. It shows statistics of all APIs. The Statistics menu is available for API creators to see statistics of only the APIs created by them.

...