mashup - Combining results of multiple API calls -
i invoking api operation fetch list of objects , then, each object in list, invoking api operation fetch additional details of object , adding details object. goal return list of objects properties (or details) need. in example below, /allobjects
call list of objects 2 properties - id
, k1
. application needs 3 properties, id
, k1
, k4
. invoke api method detailed information each object, includes k4
property. copy detailed property original result-set's object , return "enriched" result-set. latency cost of can high. best way of achieving without slowing down application much? in real world, dealing 500-2000 objects.
get /allobjects yields json results => { "data" : [ { "id" : "123", "k1" : "v1" }, { "id" : "456", "k1" : "v1" } ] } (obj in results.data) { /object/{obj.id} yields json result => { "data" : { "id" : "123", "k1" : "v1", "k2" : "v2", "k3" : "v3", "k4" : "v4" } } // add k4 property original result-set object, , assign // value of k4 property in individual result object. obj.k4 = result.data.k4; } return results.data;
your requirement such that, have no other option go mash-up(unless can convince api developers combine 2 api).
you could, however, opt make mashup service low latency cost stand in between application abstract out mashup logic, conversely, opt use language custom made kind of work program application. both of these options can accommodated ballerina, i've written post here showing how easy using it.
Comments
Post a Comment