Was this helpful?

The Apigee API Platform processes API requests and responses using a pipeline processing model. The behavior of your API is determined by the processing of both the request and response flows. The request flow processes incoming messages sent to your backend services. The response flow processes messages sent from your backend service to the client. 

Your proxy has two types of endpoints: 

  • ProxyEndpoint: Processes inbound requests from, and outbound responses to, HTTP clients. 
  • TargetEndpoint: Processes outbound requests to, and inbound responses from, HTTP services.

API Platform flow processing model

Each endpoint defines Flows that determine the order in which pre-defined processing steps are applied to messages in the request or response. Each request and response path in a ProxyEndpoint and TargetEndpoint defines the following Flow types:

  • PreFlow: Always executes before any other Flows. The processing steps defined in the PreFlow are applied to every message that passes through an Endpoint. 
  • Conditional Flows:  Execute only when a conditional statement defined for the Flow evaluates to true. An Endpoint may define any number of conditional Flows, but only the first conditional Flow whose condition evaluates to true will execute. 
  • PostFlow: Always executes after all other Flows. As with PreFlow, the processing defined for PostFlow is applied to every message. 

As shown above, API proxy flows execute in the following sequence:

Request

  1. ProxyEndpoint request PreFlow
  2. Optional conditional Flows
  3. ProxyEndpoint request PostFlow
  4. TargetEndpoint request PreFlow
  5. Optional conditional Flows
  6. TargetEndpoint request PostFlow

Response

  1. TargetEndpoint response PreFlow
  2. Optional conditional Flows
  3. TargetEndpoint response PostFlow
  4. ProxyEndpoint response PreFlow
  5. Optional conditional Flows
  6. ProxyEndpoint response PostFlow

Note: All these flows do not need to be configued in order to have a functioning proxy. A simple proxy many only have a request and response PreFlow.

RouteRule

A ProxyEndpoint must have at least one RouteRule. When you create a new proxy, it contains a default RouteRule. The RouteRule defines where the inbound request message is forwarded after it is processed by the ProxyEndpoint PostFlow. A simple API proxy usually routes message to a named Target Endpoint. However, multiple RouteRules may be configured to support conditional routing. For example, messages may be dynamically routed to different URLs or TargetEndpoints based on the value of HTTP headers, based on request message content, etc. This makes RouteRules useful for supporting versioning, for example. See Control traffic flow for an example of a RouteRule.

Modify API Proxy behavior using policies

API proxy behavior is controlled by policies. A policy encapsulates an atomic unit of management functionality.  It may rely on out-of-the-box functionality, or it may rely on scripts or code to execute custom behavior.  Policies are attached as processing steps to Flows. The policies you attach to the request Flows impact all the messages sent from an app to a backend service (that is, an inbound request and an outbound request). Policies attached to the response Flow impact messages sent from the backend service to the app (that is, the inbound response and the outbound response).

Polices can be used to manage availability and performance, or to implement custom behavior. For example, to improve availability, a Response Caching policy can be attached to Flows in the ProxyEndpoint. To expand the reach of your APIs, you might attach an XML to JSON policy to the response Flow to selectively convert outbound responses from XML to JSON based on the requesting app. For examples, refer to the Policy Reference and for working examples refer to the API Platform samples on Github. 

Editing your proxy

An API proxy is a bundle of XML files and associated code that is imported to the Apigee API Platform, where it can be deployed to any available environments for runtime execution. You can choose to model and configure your API proxy by editing the API proxy configuration files on you local machine and uploading your changes to the API Platform, or by using the Proxy Editor in the Management UI. 

To learn how to develop API proxies locally in a text editor or IDE , see Configure and deploy an API proxy. If you're more comfortable using the Management UI read Edit your API proxy.