Skip to main content

Design,Implement and Manage a RESTful API with WSO2 API Manager


A proper API has to be intuitive,well documented,consistent  and wrap with security and analytics support.This is where the importance of WSO2 API Manager product comes. WSO2 API Manager is a complete solution to design,implement and manage APIs.It comes with an out of the box  API Publisher  which allows to design the API  properly and convert it to a managed API.API Publisher is the main entry point,which is a web application in which an API developer will starts developing his API and expose it to public.

Basically API Publisher provide capabilities to cover the three API phases of design,implement and manage.

  • Design phase-

The phase in which API creator is planning and designing the API with defining the set of API resources exposed from the API.


  • Implement phase-
The phase in which API creator try to deploy the API and test it as a Prototyped API to check the designed API is working as expected.Additionally API creator can connect with back-end implementation and test it as a sandbox endpoint. Then try to connect with real production endpoint.


  • API manage phase- 
The phase in which ,API creator will engage the value added features as security,throttling to the API.This way the RESTful API will become a managed API as the API creator has engaged policies into it ,in-order to convert it to a more controllable API.

Design APIs with WSO2 API Manager

design.png

This is the starting phase of creating a good RESTful API.An API design is a proper definition for the actual back-end implementation,its supporting resources and methods.In other words,it’s the contact for end users who are willing to consume the API.Thus designing the API properly matters.Thus we have introduced API designing capability with API Publisher application in WSO2 API Manager from the released 1.7.0 on-wards.

API designing involves making the API intutitive,well documented and consistent.To achieve these,it has to properly define the API resources and well document them for consuming each.Thus in WSO2 API Manager,we have integrate swagger framework with the API resource defining function.Swagger is a declarative resource specification,which consumers could understand and consume services without knowledge of server  implementation.It' is an open source framework which will describe,visualize and consume a RESTful API.The swagger documentation of methods,parameters and models are tightly integrated to back-end implementation and it allows APIs to always in sync with implementation.

From API Publisher ,design API UI,an API developer can declare API resources with swagger in style.Swagger integration to API Publisher provide support for API developers to define API resources inline with swagger or import pre-defined API resources directly.

swaggr4.png


Implement APIs with WSO2 API Manager

Next phase is how the API developer can continue testing the designed API.Before exposing the API to public for consuming it,API developers has to properly test the API with its defined API resources set. For this, an API developer can try sampling the responses for each API definition as prototyped APIs and test or either directly connecting to the backend through WSO2 API Manager. With the prototyped APIs concept an API developer could initially test whether he has properly designed API resource definitions without costing additional network delay on connecting to actual backend implementation.The advantage of having a prototyped API is it provides early promotion for the created API.API developer could get early feedbacks from API Consumers as API consumers can consume the prototyped APIs without subscribing to them. A prototyped API can sample its implementation inline with javascript.

prototype.png

Once the API creator deploy and test the API as a prototype,now it has confirmed the API resource definitions are properly defined.Now the missing part is test with actual back-end implementation.For that,API developer can switch the implementation method in ‘Implement’ phase UI of API Publisher to back-end endpoint as shown below.Since this is for testing purposes,better to give the testing environment back-end endpoint as the sandbox url. Then as an APIConsumer a user can subscribe to this API ,generate a sandbox token and continue testing on this.

sandbox.png


Manage APIs with WSO2 API Manager

Above has covered how to design a RESTful API,test the implementation and now remaining is expose it as a managed API to the public.In this phase ,with WSO2 API Manager,an API developer can engage policies to an API as throttling ,security and expose it to public for subscriptions.There are more value added features in API manage phase like restrict the API exposing transport either to be http or https,engage additional mediation logics via sequences to fire during API invocations,control API subscriptions.Additionally API Publisher provides capability of managing the API life-cycle.

manage.png


Comments

  1. Can we import/export api manager's API from one computer to another ?

    ReplyDelete
  2. Hi Pantomath,

    This feature is available from AM 1.9.0.Please refer https://docs.wso2.com/display/AM190/Migrating+the+APIs+to+a+Different+Environment

    ReplyDelete
  3. Thanks for Sharing This Article.It is very so much valuable content. I hope these Commenting lists will help to my website
    mulesoft online training

    ReplyDelete

Post a Comment

Popular posts from this blog

Convert an InputStream to XML

For that we can use DocumentBuilder class in java. By using the method parse(InputStream) ; A new DOM Document object will return. InputStream input; DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); DocumentBuilder parser = factory.newDocumentBuilder(); Document dc= parser.parse(input); In the above code segment,by using the created Document object,the corresponding XML file for the inputStream can be accessed. References: http://www.w3schools.com/dom/dom_intro.asp http:// download.oracle.com/javase/1.4.2/docs/api/javax/xml/parsers/DocumentBuilder.html

CORS support from WSO2 API Manager 2.0.0

Cross-origin resource sharing (CORS) is a mechanism that allows restricted resources  on a web page to be requested from another domain outside the domain from which the first restricted resource was served. For example, an HTML page of a web application served from http://domain-a.com makes an <img src >  request for a different domain as 'domain-b.com' to get an image via an API request.  For security reasons, browsers restrict cross-origin HTTP requests initiated from within scripts as in above example and only allows to make HTTP requests to its own domain. To avoid this limitation modern browsers have been used CORS standard to allow cross domain requests. Modern browsers use CORS in an API container - such as  XMLHttpRequest  or Fetch - to mitigate risks of cross-origin HTTP requests.Thing to  note is it's not only sufficient that the browsers handle client side of cross-origin sharing,but also the servers from which these resources getting need to handl

[WSO2 AM] APIStore User Signup as an approval process

In previous versions of WSO2 APIManager before 1.6.0, it was allowed any user who's accessible the running APIStore come and register to the app.But there will be requirement like,without allowing any user to signup by him/her self alone,first get an approve by a privileged user and then allow to complete app registration.Same requirement can be apply to application creation and subscription creation as well.To fulfill that,we have introduced workflow extension support for  WSO2 APIManager  and you can find the introductory post on this feature from my previous blog post on " workflow-extentions-with-wso2-am-160 " . From this blog-post,I'll explain how to achieve simple workflow integration with default shipped resources with  WSO2 APIManager 1.6.0 and WSO2 Business Process Server 3.1.0 with targeting "user-signup" process. Steps First download the WSO2 APIManager 1.6.0[AM] binary pack from product download page . Extract it and navigate to