{ Community }
  • Academy
  • Docs
  • Developers
  • Resources
    • Community Articles
    • Apigee on GitHub
    • Code Samples
    • Videos & eBooks
    • Accelerator Methodology
  • Support
  • Ask a Question
  • Spaces
    • Product Announcements
    • General
    • Edge/API Management
    • Developer Portal (Drupal-based)
    • Developer Portal (Integrated)
    • API Design
    • APIM on Istio
    • Extensions
    • Business of APIs
    • Academy/Certification
    • Adapter for Envoy
    • Analytics
    • Events
    • Hybrid
    • Integration (AWS, PCF, Etc.)
    • Microgateway
    • Monetization
    • Private Cloud Deployment
    • 日本語コミュニティ
    • Insights
    • IoT Apigee Link
    • BaaS/Usergrid
    • BaaS Transition/Migration
    • Apigee-127
    • New Customers
    • Topics
    • Questions
    • Articles
    • Ideas
    • Leaderboard
    • Badges
  • Log in
  • Sign up

Get answers, ideas, and support from the Apigee Community

  • Home /
  • Edge/API Management /
avatar image
1
Question by Nagashree B · Jan 29, 2015 at 05:43 AM · 5.9k Views api proxyapi managementapi design

API chaining

If I have a scenario where one api proxy needs to call another API, what is the best way to do it?

I checked the javascript mashup example. Do both API calls essentially pass through the API gateway or can they be handled by the message processor itself? (i am checking on the latency here)

I checked the best practices link, it said DO NOT use service callout to invoke a proxy from inside another proxy. Pls let me know the most efficient way to do it.

Comment
Add comment Show 1
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image owen rubel · Mar 02, 2015 at 06:42 PM 0
Link

Do not confuse 'method chaining' with 'api chaining'. API Chaining is a client-side IO Monad that allows clients to dynamically create chains using one request/response to return data. This is EXTREMELY useful for mobile applications but cannot be done using the 'old' api pattern; one must implement the 'new' api pattern wherein the communication logic is abstracted from business logic.

Close

3 Answers

  • Sort: 
avatar image
1

Answer by Michael Malloy   · Jan 29, 2015 at 05:32 PM

There are two reasons why the best practices mentions to not use a Service Callout to call another proxy

  • Performance - A Service Callout to another proxy uses more resources. Latency for a Service Callout to another API proxy will be slightly slower than calling the API directly
  • Circular References - You will get unexpected results if a chain of API calls ends up calling the same API twice

Generally, it is better to avoid calling one API from within another, but if you are in a position where you have to do that, you will need to use a Service Callout. If you end up doing that, please take extra care to ensure that there are no circular references in your API chain.

Comment
Add comment Show 6 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image owen rubel · Feb 28, 2015 at 03:36 PM 0
Link

The circular reference isn't slower and is the better solution as it provides a push/pull mechanism for forwards/redirects (thus avoiding a dropped thread and IO binding when redirecting to proxy/api gate). You do this in an Interceptor.

avatar image Michael Russo ♦ owen rubel   · Mar 02, 2015 at 06:39 PM 0
Link

Michael's answer is in the context of the Apigee Edge product and how Edge API proxies perform when you chain them together. API proxy chaining in this context is:

client <--> api proxy 1 <--> api proxy 2 <--> api backend service

where api proxy 1 and api proxy 2 exist in the same platform, but have no direct relationship in their code processing. Communication between api proxy 1 and api proxy 2 is HTTP requests leaving the platform and then entering the same platform for the same request going to the api backend service.

avatar image owen rubel Michael Russo ♦ · Mar 02, 2015 at 11:39 PM 0
Link

But the question was on API Chaining. As stated, this is 'method chaining'. The API pattern binds communication logic to business logic through the data (ie RestfulController, JAX, etc). As such, one cannot separate the data from functionality unless one abstracts the communication logic. Thus when doing a forward/redirect to Apigee Edge, the same problem occurs... dropped thread, IO bound processes.

Within the context of Apigee Edge and abstracting the communication layer to an Interceptor, one can avoid this architectural cross cutting concern. Make sense?

avatar image owen rubel Michael Russo ♦ · Mar 03, 2015 at 12:14 AM 0
Link

Oh and an api chain is actually done like so...

https://github.com/orubel/grails-api-toolkit-docs/wiki/API-Chaining

Not trying to be rude. Just trying to avoid alot of assumptions being made here.

Show more comments
avatar image
1

Answer by Nagashree B   · Jan 30, 2015 at 06:01 AM

Thanks Micheal. In essence you would say that, it is better to call the backend service (target url) directly from within an API proxy using service callout rather than calling another proxy pointing to the target url; and this would give better performance.

Comment
Add comment · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by owen rubel · Feb 13, 2015 at 10:24 PM

API Chaining is a pattern created by Owen Rubel and shown at ApiDays (see spec for api chaining - https://github.com/orubel/grails-api-toolkit-docs/wiki/API-Chaining). It is an IO Monad relying on IO State wherein a client can send a string of inter-related apis which the backend can batch in one request/response without requiring any hardcoding ahead of time (ie everything is automated).

This CANNOT be achieved using the existing API pattern as communication logic and business logic are bound with IO data being bound as well and unshareable across the architecture creating an architectural cross cutting concern.

The new API pattern moves communication logic to a higher layer and unbinds IO state so it can be shared thus creating a more automatable api, greater CPU bound processes vs IO bound processes, less code, less tooling, greater scalability, easier deployability, etc.

See this video for an example of IO state in API Architecture ( )

As for Michaels statement about slowness, this is incorrect. When communication layer is separated from business logic so that IO state can be shared across architecture, this allows for a push/pull mechanism. In Spring framework we call it a handlerInterceptor. We can intercept the request/response and loop them back when doing forwards/redirects. This allows for greater automation of data checks, role checks, batching, api chaining, etc

So there is no speed loss. In fact, by GREATLY reducing mobile throughput, there is a huge speed GAIN! And because you can use a common returned resource for your api, you can cache that object easier and your api calls are greatly sped up.

Comment
Add comment Show 2 · Link
10 |5000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by Apigeeks only
  • Viewable by the original poster
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Michael Russo ♦   · Mar 02, 2015 at 06:46 PM 0
Link

I voted this answer down as it doesn't pertain to the Apigee Edge platform, which is the context of the question being asked. I understand your statements about API chaining in general, but they aren't accurate for implementations on the Edge platform at this time.

avatar image owen rubel Michael Russo ♦ · Mar 03, 2015 at 12:12 AM 0
Link

Actually it does if you understand it. The API instance needs to abstract the communication logic from business logic to avoid the issue. The issues you are talking about are incorrect implementations of the API pattern in concerns with architecture which cause architectural; cross cutting concerns in relation to communication functionality/data in the API instance.

This directly relates to the question as that is HOW API chaining is done; anything else is 'method chaining'

Follow this Question

Answers Answers and Comments

9 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How do you know what changes are made to a proxy revision? 2 Answers

Server Error: NTLM authentication problem 0 Answers

What happens by to any resources, query params, headers, and request body in a request to an API proxy? 1 Answer

Can I make policies reusable? 3 Answers

SOAP API WSDL not available 1 Answer

  • Products
    • Edge - APIs
    • Insights - Big Data
    • Plans
  • Developers
    • Overview
    • Documentation
  • Resources
    • Overview
    • Blog
    • Apigee Institute
    • Academy
    • Documentation
  • Company
    • Overview
    • Press
    • Customers
    • Partners
    • Team
    • Events
    • Careers
    • Contact Us
  • Support
    • Support Overview
    • Documentation
    • Status
    • Edge Support Portal
    • Privacy Policy
    • Terms & Conditions
© 2021 Apigee Corp. All rights reserved. - Apigee Community Terms of Use - Powered by AnswerHub
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Create an article
  • Post an idea
  • Spaces
  • Product Announcements
  • General
  • Edge/API Management
  • Developer Portal (Drupal-based)
  • Developer Portal (Integrated)
  • API Design
  • APIM on Istio
  • Extensions
  • Business of APIs
  • Academy/Certification
  • Adapter for Envoy
  • Analytics
  • Events
  • Hybrid
  • Integration (AWS, PCF, Etc.)
  • Microgateway
  • Monetization
  • Private Cloud Deployment
  • 日本語コミュニティ
  • Insights
  • IoT Apigee Link
  • BaaS/Usergrid
  • BaaS Transition/Migration
  • Apigee-127
  • New Customers
  • Explore
  • Topics
  • Questions
  • Articles
  • Ideas
  • Badges