Understanding Business APIs through
Amila De Silva
• Providing the only complete open source componentized cloud
– Dedicated to removing all the stumbling blocks to enterprise agility
– Enabling you to focus on business logic and business value
• Recognized by leading analyst firms as visionaries and leaders
– Gartner cites WSO2 as visionaries in all 3 categories of
– Forrester places WSO2 in top 2 for API Management
• Global corporation with offices in USA, UK & Sri Lanka
– 200+ employees and growing
• Business model of selling comprehensive support &
maintenance for our products
● Role of Statistics in API Management
○ Statistics to understand user communities
○ As tool for making strategic decisions.
● Different Options for analysing data
○ Phases in Data analysis
○ Offline vs Real-time analysis
● BAM as an offline data analytic engine
○ How large event streams gets summarized
● CEP for real time processing
○ Architecture of CEP
○ Stages of an execution plan
● GA as a feedback channel for app developers
● Options for visualising data.
○ Generating reports out of BAM summarized data.
APIs - the way to go
● APIs are no longer a luxury - they are
becoming a necessity.
● API - A common interface for disparate
● More open you are more users you will
● Build an ecosystem around your APIs.
Why do you need statistics?
● There are many connected components
● One wrong move can make disastrous
● Feedback channels are important -
○ See how users access them and learn - It
explains what they say.
● Discover hidden potentials within your
○ Going for a new billing model - See how users
● Can you check them all manually?
What we provide
● Two branches in analysis
○ Offline Data analysis
○ Realtime Analaysis
● Offline Data Analysis
○ Gives you a general idea of your APIs
○ Who your users are.
○ Leads you to make long term decisions.
● Realtime analysis
○ Identifies co-occurrence of several useful business
○ Find and act on it.
How we analyse it
● Done in two main phases
○ Data Gathering
● Gather data at product level.
○ multiple event streams for request, response and faults
○ each invocation as an event
● Delegating analysis to a different product
○ Simply any tool capable of processing event streams can
○ Currently BAM and CEP are used.
● Extensions to achieve product specific analysis
○ In BAM this is done through a hive script
○ In CEP this can be done by a transport adaptor + execution
● Event = Invocation
● In the gateway we collect data related to
● Three different event streams
○ Request Stream
○ Response Stream
○ Fault stream
Analysing Data with BAM
● Used for offline Analysis.
● Aggregates, stores, then analyses data.
● Capable of receiving events from multiple data
○ In APIM 1.5.0 we use a load balancing data publisher.
● All the incoming events are first written to a
● Data analysed using a hive script running on top of a
● Summarised data written back to a Relational DB.
Analysing Data with BAM...
Visualizing summarized data
Analysing with BAM...
Summarized data usages for billing
● Decide on a billing model
● Integrate with existing billing engines
Real-time Analysis with CEP
● APIM can publish events to multiple data
● Same streams are used to publish events to
● Whenever it receives a new event CEP
executes a query and evaluates the event.
● Siddhi queries define the evaluation criteria.
● Transport Adaptors to read/write event
○ We can create alternate event streams out of the
● Event builders convert events to a standard
● Queries defined as query plans.
● Event processor executes a query plan.
○ It might generate additional events.
● Event formatters convert back the output.
● Task : Identify client applications sending too
many repeated requests
○ Too Many : 5 requests
○ repeated : within 1 minute
● How to identify a client
○ Consumer key
And the query is:
from AMRequest#window.time(1 min)
insert into outStream
count(consumerKey) as myCount,api_version,api,consumerKey
group by consumerKey,api_version,api
having (myCount > 5);
Flow in CEP...
● Transport adaptor reads requestStreamDefn
● Creates a second input stream AMRequest
○ This only contains subset of data.
● Event builder transform the input stream
● Query is defined in a query plan.
○ Even processor executes each of the registered query
● Upon meeting the condition an event is generated.
● Event formatter converts the event.
● Mail is sent through the transport adaptor.
Monitoring Statistics with Google
• API Manager can be easily configured with Google Analytics
● Needed for interpreting statistics.
● Gadgets provided in BAM
● Plugin any external tool for generating reports
● Combining summary tables to create new
• Statistics as a channel to verify business objectives.
• WSO2 API Manager provides different mechanisms to analyze
• WSO2 BAM can be integrated with API Manager process
• Gather -> Cassandra
• Analyze -> Relational DB
• WSO2 CEP can be integrated with API Manager and real time
• Google Analytics integration with API Manager.
Engage with WSO2
• Helping you get the most out of your deployments
• From project evaluation and inception to development
and going into production, WSO2 is your partner in
ensuring 100% project success