DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports Events Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones AWS Cloud
by AWS Developer Relations
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Partner Zones
AWS Cloud
by AWS Developer Relations
  1. DZone
  2. Data Engineering
  3. Databases
  4. API Manager WSO2

API Manager WSO2

In this brief article, I am going to demonstrate how easy and cool it is to use the API Manager provided by WSO2.

Anupam Gogoi user avatar by
Anupam Gogoi
·
Aug. 07, 18 · Tutorial
Like (12)
Save
Tweet
Share
11.35K Views

Join the DZone community and get the full member experience.

Join For Free

Introduction

In this brief article, I am going to demonstrate how easy and cool it is to use the API Manager provided by WSO2. For this tutorial, I am using the API Manager Version 2.5.0.

Installation and Running

Installation is quite straightforward. You can either use the Cloud edition or an on-premise edition. For this demo, I have chosen the binary on-premise version.

Image title

After downloading the binary file, extract the zip file in some directory in your system and navigate to the bin directory. Then execute the wso2server.sh in Linux or wso2server.bat in Windows.

Note: It's mandatory to set the JAVA_HOME environment variable in your OS. In my case, the installation was done successfully with Java 8.

Key Services

After properly running the API Manager, you will be provided with some important endpoints. In this demo, I will show only the store and publisher endpoints.

API Store: https://localhost:9443/store/

API Publisher: https://localhost:9443/publisher

For both services use: username=admin and password=admin

API Publisher

API Publisher is the main entry point where you design your APIs using Swagger.

URL

Login

Password

https://localhost:9443/publisher

admin

admin

Design

Here, you design the API using the Swagger specification. It's kind of Design Center in Anypoint Platform. Here is a screenshot,

Image title

In the Design tab, you can create the API resources either visually or by editing Swagger source just by clicking the Edit Source button. Or if you have previously created API you can import it directly.

Small Note for URL Pattern

The URL Pattern is something that will uniquely identify the API. For this example, let's suppose that the URL Pattern is /app/v1. Let's suppose that we have defined two resources in the Swagger specification.

1. GET /users

2. GET /tag

When the API will be published the resources will be available at http://localhost:8280/app/v1/usersand http://localhost:8280/app/v1/tagrespectively. (Host & Port are subject to change as per your configuration)

Implement

This is an interesting part. Here, you provide the actual implementation URL of the API. Image title

For example, I have implemented an API and the resources are available at the following URLs,

GET http://localhost:8081/stats/users

GET http://localhost:8081/stats/tag

So, how does the mapping of the URLs work? Here comes the role of the URL Pattern from the previous section.

URL Pattern

Actual Endpoint

http://localhost:8280/app/v1

http://localhost:8081/stats

http://localhost:8280/app/v1/users

http://localhost:8081/stats/users

http://localhost:8280/app/v1/tag

http://localhost:8081/stats/tag

URL Pattern is somewhat kind of Proxy as in the API Manager of Anypoint Platform. So, basically, we will define the Production and Sandbox endpoint as http://localhost:8081/stats

Note: It's up to you how you define the strategy.

Manage

In the Manage tab, you simply apply the rate-limiting kind of stuff etc. Here is a screenshot,

Image title

After setting up the configuration publish the API. Once the API is published successfully it will be available in the API Store section.

API Store

API Store is basically a central location for all published APIs. Here, the published APIs can be consumed by creating Application and subscribing to that APIs.

URL

Login

Password

https://localhost:9443/store

admin admin

APIs

Here you can find a list of the Published APIs. It's similar to Exchange in Anypoint Platform.

Image title

You can click the API to get detailed information of it.

Image title

You can check the URL of our API.

Applications

Applications can be created easily in this section. There are two Token types available OAuth & JWT.

Image title

Once an application is created, you are provided with a very informative page to explain how to get the Access Token and use it in the requests.

Image title

In my case, the following command has been executed to get the access_token,

curl -k -d "grant_type=client_credentials" -H "Authorization: Basic XzY3TWRjeHBaSHdVT0o4NndibWM2VXBaRFlvYTpMOFRzR05HNmJOVVJ3bzdBY2dNQjZmSk02YXdh" https://172.17.0.1:8243/token 

Once access_token is in hand, the API can be called easily providing the token as Authorization header.

Image title

Check the URL we are accessing. This is the kind of proxy URL to our actual implementation URL.

Conclusion

In this tutorial, I have shown how easy it is to use the API Manager provided by WSO2. The best thing about the API Manager is that it can be downloaded, installed, and run in your local system very easily without the least effort. Apart from providing easy API management facilities, there are other cool features included in the product. In my next articles, I will try to explain them.

API

Opinions expressed by DZone contributors are their own.

Popular on DZone

  • How to Submit a Post to DZone
  • 11 Observability Tools You Should Know
  • Spring Boot vs Eclipse Micro Profile: Resident Set Size (RSS) and Time to First Request (TFR) Comparative
  • Multi-Cloud Integration

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 600 Park Offices Drive
  • Suite 300
  • Durham, NC 27709
  • support@dzone.com
  • +1 (919) 678-0300

Let's be friends: