Skip to content
Branch: master
Find file History
Type Name Latest commit message Commit time
Failed to load latest commit information.
apiproxy change the Facebook target URL to Nov 30, 2016 update read me to use the new format and add additional information. Nov 30, 2016 fixed twitter target Aug 3, 2016 fixed twitter target Aug 3, 2016

Dynamic Endpoint URI

Sample use case

Demonstrate the ability to change the target endpoint of an API proxy dynamically at runtime.


In this sample, the request is either routed to Facebook or Twitter based on the value passed to the "routeTo" query parameter. For example, the following cURL command directs the request to Twitter:

curl "http://$org-$env.$api_domain/dynamic-endpoint?routeTo=tw"

This approach could also be used to dynamically route requests between different backend environments, such as testing and production environments, sandbox and production APIs, and so on.

This example uses a route rule in the ProxyEndpoint definition:

<ProxyEndpoint name="default">
	<RouteRule name="fbroute">
		<Condition>request.queryparam.routeTo = "fb"</Condition>
	<RouteRule name="twroute">
		<Condition>request.queryparam.routeTo = "tw"</Condition>
	<RouteRule name="default">

In the route rule, the target endpoint of the request is determined by the value of the "routeTo" query parameter. If the "routeTo" query parameter is omitted, the default action is to pass the request to Twitter.

See the target endpoint definitionsin the target directory of the proxy to see how these endpoints are defined.

Set up, deploy, invoke

See the main project README file for information about setting up, deploying, and invoking sample proxies.

To deploy, run $ sh

To test, run $ sh

The script first invokes the proxy with routeTo=fb and then with it set to routeTo=tw.

More information

For more on route rules, see:

Ask the community

alt text

Copyright © 2016 Apigee Corporation

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You can’t perform that action at this time.