API aggregation and mash-ups

501 views
Skip to first unread message

Tom Davidson

unread,
Dec 5, 2016, 2:11:21 PM12/5/16
to LoopbackJS
I am evaluating Loopback to aggregate and mash up our internal APIs and would appreciate anyone's experiences solving similar problems.

My published API has a Swagger contract and the internal/aggregated APIs have Swagger as well.  I can import my published API Swagger and create modules - way cool. I can also use the loopback-connector-swagger - again way cool. But then what?


sim...@ca.ibm.com

unread,
Dec 7, 2016, 4:52:22 PM12/7/16
to LoopbackJS
Your question is kind of generic, what are you trying to achieve with your API? It sounds like it's working and you're up and running successfully?

Raymond Feng

unread,
Dec 7, 2016, 5:02:11 PM12/7/16
to loopb...@googlegroups.com
Tom, 

You hit the nail. We allow you to use JavaScript to aggregate and mashup off internal APIs. See https://loopback.io/doc/en/lb2/Remote-methods.html.

We may add declarative solutions for the composition in the future.

Thanks,
Raymond
--
You received this message because you are subscribed to the Google Groups "LoopbackJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to loopbackjs+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/loopbackjs/f6247a57-d45e-43c8-87df-02d6488b088e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Tom Davidson

unread,
Dec 7, 2016, 6:23:25 PM12/7/16
to loopb...@googlegroups.com
Your question is kind of generic, what are you trying to achieve with your API? It sounds like it's working and you're up and running successfully?

​Not successfully​. Complete newb here. I and another engineer spent most of last friday on our first exposure to loopback. We were not able to making an oauth request with loopback-connector-swagger but gain a few hours of loopback exposure. We are evaluating solutions rather than deploying one.

​We need an outer layer API aggregator and mashup tool to expose our many internal APIs. In our case we have a few dozen business domains, each with their own internal API.  I am looking at loopback as a tool to publish a universal public API (UAPI).  Each top-level resource of the UAPI depends on one or more internal APIs. We have developed the Swagger for UAPI and I have played around with importing the Swagger doc to generate models. Each internal API also has Swagger, hence the attempted use of loopback-connector-swagger.

Im content with each UAPI top level resource being a different web app - we can partition from our service gateway but I am also open to one web app for the entire UAPI as long as we can structure it such away easily  deploy changes about once a week.


We allow you to use JavaScript to aggregate and mashup off internal APIs. See https://loopback.io/doc/en/lb2/Remote-methods.html.

So in the model file (that was generated via Swagger import)  I use remote-methods as the connection to the datasource via the internal loopback API? I use an operational hook on the model's find method? And I can aggregate the response of multiple remote methods into find() response?




sim...@ca.ibm.com

unread,
Dec 7, 2016, 8:52:56 PM12/7/16
to LoopbackJS
I see, makes sense. Unfortunately, we don't have any solutions OOB at this time for declaritive composition and is being considered on the roadmap.

As Raymond suggested, you can write JavaScript via custom remote methods to do what you want. In your case, you can write up an external facing API/microservice with N models that expose remote methods that use the Swagger, REST, etc connector to connect to your internal APIs as a datasou


So in the model file (that was generated via Swagger import)  I use remote-methods as the connection to the datasource via the internal loopback API? I use an operational hook on the model's find method? And I can aggregate the response of multiple remote methods into find() response?
Everything up the operational hook part is good. You code up the entire remote method to make N requests to your other services (via regular JavaScript, ie. Async, Promises, etc) and aggregate them in code. This means you can call the find operation when writing up your remote method for that particular model and aggregate the response before returning from the remote method.

The operation hooks are separate in that you can perform other operations before/after certain operations that are triggered as part of the remote method invocation (operation lifecycle hooks).

Tom Davidson

unread,
Dec 7, 2016, 11:54:19 PM12/7/16
to loopb...@googlegroups.com
​Thank you for the explanation.  I had completely misunderstood the remote methods and the terminology still seems odd (presumably do to my lack of loopback understanding). I will chase it down some more. 

In your opinion is loopback an appropriate framework for this use case?


sim...@ca.ibm.com

unread,
Dec 8, 2016, 1:19:58 PM12/8/16
to LoopbackJS
IMO, yes but I'm biased since I work on the framework. I would say continue with your evaluation to see if it fits your needs.
Reply all
Reply to author
Forward
0 new messages