The Apigee Edge API samples contains the sample API proxies, policies, code, and tools that illustrate the capabilities of Apigee Edge API Services described below.

For instructions on using the samples, see Using the samples.

Doc samples

A set of samples are provided for the API proxy cookbook topics.

Name Description Policy Types Resources
javascript-cookbook Demonstrates a simple JavaScript snippet that adds HTTP headers from variables, transforms an XML-formatted weather report from JSON to XML, and trims content down for mobile clients.

Javascript
XMLToJSON

 

minimie.js
setHeaders.js
javascript-mashup-cookbook A complete JavaScript application that calls to public APIs, combines results, and generates an enriched response for the client app. (Note: this API proxy implements the same functionality as the policy-mashup, demonstrating that the same problem can be addressed using different techniques.) Javascript MashItUp.js
java-cookbook Looks up a weather forecast using Java written to the JavaCallout API. JavaCallout
RaiseFault
CityLookup.jar
policy-mashup-cookbook A complete application that uses policy composition to call two public APIs, combines results, and generates an enriched response for the client app. (Note: this API proxy implements the same functionality as the javascript-mashup, demonstrating that the same problem can be addressed using different techniques.) AssignMessage
ServiceCallout
ExtractVariables
Javascript
XMLToJSON
GenerateResponse.js
nodejs-baas-cookbook Demonstrates how to create a simple BaaS solution using Node.js on Apigee Edge. The Node.js code orchestrates calls to the API BaaS data store, executes custom logic, and returns appropriate responses. none

config.js
server.js

Sample API proxies

The following API proxies are available in this distribution:

Name Description Policy Types Resources
access-entity Shows how to retrieve profiles for entities from the Apigee Edge datastore. AssignMessage
AccessEntity
ExtractVariables
none

advanced-api-services

This sample contains two API proxies that integrate API services and APIBaaS authentication and authorization. One proxy distributes access tokens and the other validates access tokens. The access token for APIBaaS is embedded int he API services access token, enabling seamless mediation from the API proxy to the API backend on APIBaaS. Note that these proxies are intended to be more functional than instructive. If you are just learning how to build API proxies, skip this one. none none
apikey Implements simple API key validation VerifyAPIKey
AssignMessage
Quota
none
async-callout Demonstrates a simple asynchronous callout using the JavaScript httpClient. Javascript assemble_reponse.js
callout.js
base64encoder Demonstrates how to call JavaScript includes from JavaScript resources in API proxies. AssignMessage
Javascript
core-min.js
enc-utf16-min.js
enc-base64-min.js
encodeAuthHeader.js
conditional-policy Implements simple conditional policy enforcement. When a request contains an HTTP header responsetime:true, a policy executes a Python script that adds a set of performance metrics to the response message, as HTTP headers Script (Python) timer.py
dynamic-endpoint Implements simple conditional routing in a slightly more complex scenario, that defines two URLs and one default route. none none
jira-release-notes This is the API proxy used by the Apigee doc team to generate release notes from Jira. JSONToXML
XSL
releasenotes_api.xsl
json-patch-app-services This sample enables PATCH requests for the Apigee API BaaS API, which does not support PATCH natively, using a combination of GET and PUT. Javascript
get-original-json.js
lib.json-patch-duplex.js
patch-and-make-put.js
oauth-advanced A complete, working example of the authorization code grant type flow, with Apigee Edge as the authorization server. 

GenerateAccessToken
GenerateAuthCode
RefreshAccessToken

Many others...

see the example code
oauth-authcode

Deprecated. We recommend that you look at the oauth-advanced sample instead.

   
oauth-client-credentials Demonstrates a fully functional OAuth 2.0 token endpoint configured for the client credentials grant type. GenerateAccessToken none
oauth-login-app Deprecated. We recommend that you look at the oauth-advanced sample instead.    
oauth-verify-accesstoken Demonstrates an API proxy that is configured to validate OAuth 2.0 access tokens and verify Quota. VerifyAccessToken
Quota
none
oauth10a-3legged Demonstrates an OAuth 1.0a three-legged configuration. GenerateAceessToken
GenerateRequestToken
ServiceCallout
VerifyAccessToken
none
outbound-oauth Uses the Microsoft Azure translator API to translate tweets. To do so, it makes an outbound call to obtain an OAuth access token, and then caches the token using the API Services caching policies, reusing the cached token each time an outbound call is made. Also, includes a demonstration browser app used to invoke the API proxy. AssignMessage
LookupCache
PopulateCache
Javascript
api-config.js
api-token-get.js
translate-query.js
translate-results.js
pagination Paginates an XML response message based on limit and offset parameters provided by the client AssignMessage
ExtractVariables
ResponseCache
VerifyApiKey
XSL
paginate.xslt
response-cache Demonstrates how to cache weather forecasts on Edge for 10 minutes. ResponseCache
AssignMessage
none
simple-python Demonstrates a simple scenario of attaching a python script in the
response that adds a header value to it.
Script (Python) setHeader.py
soap Demonstrates an XSL transformation that rewrites a WSDL file in response to a request with the query parameter ?wsdl. AssignMessage
ExtractVariables
Script (Python)
XSL
calculateaddress.py
fixwsdl.xsl
streaming Demonstrates an HTTP streaming configuration. none none
target-reroute Demonstrates using JavaScript to dynamically select a target URL based on the the content of a request message. ExtractVariables
Javascript
rewriteTargetUrl.js
twitter-mobile-timeline Demonstrates how to use JavaScript to strip out unneeded parameters from tweets, resulting in a streamlined Twitter timeline that is friendly for resource-constrained mobile devices. AssignMessage
Javascript
MobileTimeline.js
twitter-oembed Transforms timeline responses (e.g. from statuses/user_timeline.json) into an oEmbed response that contains the timeline data as rich HTML content. AssignMessage
JavaScript
search-oembed.js
variables Demonstrates how to extract and set variables based on transport and JSON and XML message content. AssignMessage
ExtractVariables
XMLToJSON
minimize.js
xmltojson Converts a Yahoo API weather report from XML to JSON. XMLToJSON
JSONToXML
none

Reference and Tools

/schemas

XML schema files that you can use as a reference when configuring API proxies, policies, API products, and developer and app profiles.

/tools

Contains a deployment tool, deploy.py, that imports an API proxy to an organization on Apigee Edge and then deploys it to the environment specified.

 

Share your experience

Share your experiences on the Apigee Developer Forum.

Help or comments?

  • Something's not working: See Apigee Support
  • Something's wrong with the docs: Click Send Feedback in the lower right.
    (Incorrect? Unclear? Broken link? Typo?)