Apigee API Platform Samples

repository·master·Indexed 19 days ago

https://github.com/apigee/api-platform-samples

A collection of sample API proxies for Apigee Edge, Apigee X, and Apigee hybrid. These samples help developers learn and test API management patterns including security, quota enforcement, transformations, Java Callouts, and Node.js Hosted Functions. The repository includes default proxies like helloworld and oauth, as well as specialized samples for Hosted Targets and Java-based response conversion and error handling.

Tokens
57.2K
Snippets
173
Records
272
Agent score
67%

What's inside apigee-api-platform-samples

  1. Overview of Tutorial Demos

    master

    The Tutorial Demos in this repository are designed to demonstrate technical and industry use-cases using APIs and cloud technologies. Each demo is intended to be used alongside a specific tutorial codelab and typically includes:

    • A link to a running example.
    • Deployment instructions.
    • A corresponding tutorial codelab to explain the underlying mechanics.
  2. Overview of Apigee API sample proxies

    master

    The sample-proxies directory contains self-contained Apigee Edge API proxy samples designed to demonstrate various development techniques and patterns. These samples cover common API management tasks such as:

    • Data transformations
    • API key validation
    • Target URL rewriting
    • Quota enforcement
    • Security implementations (OAuth, API Keys)

    Each sample is designed to be independent and includes its own scripts for deployment and invocation.

  3. Overview of the Jira release notes generator

    master

    This sample API proxy integrates with the Jira API to generate HTML-formatted release notes. It works by fetching issues from Jira that are tagged with a release_notes label. The proxy performs the following transformation pipeline:

    1. Fetches JSON data from the Jira API.
    2. Converts the JSON response to XML using a JSON to XML policy.
    3. Applies an XSL Transform policy using an XSL stylesheet to generate the final HTML.

    The stylesheet specifically extracts text from a "Release Notes Summary" field. It also supports new_feature and known_issue labels, which are automatically categorized into their respective sections in the generated HTML.

    If your Jira environment uses different fields, you must modify the URI query parameters (and the invoke.sh script if used) and update the .xsl resource file.

  4. Overview of Advanced API Services Token Generation

    master

    This sample integrates Advanced API Services (formerly App Services) security features into the Apigee gateway. It provides a unified authentication and authorization mechanism for applications consuming a combination of back-end services and data.

    The proxy exposes a single endpoint: /v1/datastore/token.

    Supported Operations:

    • OAuth Resource Owner Password Grant: Token generation using grant_type=password.
    • OAuth Client Credentials Grant: Token generation using grant_type=client_credentials.
    • Token Invalidation: Revoking existing tokens.
  5. Overview of the Maps Demo

    master

    The Maps Demo is an Apigee proxy sample that wraps the Google Maps API. It demonstrates how to use an Apigee proxy to augment third-party API responses with additional data without requiring external hosting for services or client applications.

    Key features include:

    • Weather Augmentation: Adding weather information to location searches.
    • Feature Flagging: Using a feature flag to conditionally include pizza information about searched locations.
    • Zero Hosting: The logic is handled entirely within the Apigee proxy layer.
  6. Overview of the Javascript Composite Service ("Mashup") sample

    master

    This sample demonstrates how to create a 'Mashup' API Proxy using a JavaScript application instead of standard Apigee policies. The proxy aggregates data from two external APIs:

    1. Google Geocoding API
    2. Google Elevation API

    The resulting JSON response combines the geocoded location (latitude/longitude) for a specific postal code with the elevation data for that location. This sample is useful for comparing the tradeoffs between using custom JavaScript scripting versus using built-in Apigee policies for service composition.

  7. Explore the helloworld sample proxy resources

    master

    The helloworld proxy routes calls to http://mocktarget.apigee.net and provides several endpoints to test different response formats and behaviors. It includes a Quota policy and an Assign Message policy for CORS support.

    Available resources via the proxy BasePath (/v0/hello):

    • /v0/hello (Base Path): Returns Hello, Guest!
    • /v0/hello/user: Returns Hello, Guest!
    • /v0/hello/user?user=your_name: Returns a customized greeting.
    • /v0/hello/iloveapis: Returns <H2>I <3 APIs</H2>
    • /v0/hello/ip: Returns the client IP address as JSON.
    • /v0/hello/xml: Returns a sample XML response.
    • /v0/hello/json: Returns a sample JSON response.
    • /v0/hello/echo: Returns request headers and the request body as JSON.
    • /v0/hello/help: Returns a help page of available resources in HTML.
  8. Understand the OAuth 2.0 token verification sample

    master

    This sample API proxy demonstrates how to protect a resource using OAuth 2.0 access tokens. It performs two primary functions:

    1. OAuth 2.0 Validation: Validates the incoming access token for the request URL and retrieves attributes from the associated API Product.
    2. Quota Enforcement: Uses the Quota policy to rate-limit client applications based on settings defined in the API Product.

    Note: Because this flow requires an access token to be generated before the protected resource can be accessed, the provided invoke.sh script includes a guided flow to generate the token automatically.

  9. Use the Java error handling sample

    master

    This sample proxy demonstrates how to implement error handling patterns within a Java Callout. It is specifically designed to show how to:

    • Return custom error messages and headers back to the client.
    • Set flow variables in Apigee Edge that can be used for debugging purposes.

    This sample is intended to complement the Apigee Edge documentation on How to handle Java Callout errors.

  10. Use the Apigee Organization Snapshot Tool

    master

    The Apigee Organization Snapshot Tool is a collection of bash scripts used to retrieve and backup organization settings such as developers, API products, virtual hosts, and key/value maps. It can also be used to discover settings or to retrieve configurations from two different organizations for comparison using a file diff tool.

    Important Limitations:

    • The tool is read-only; it does not update or modify any settings in the organization.
    • It does not capture every possible setting.
    • It does not download API proxies. Use the management UI or management API for proxy retrieval.
    ./apigee-getorg.sh -e {admin-email} -s {mgmtserver} -o {org-name} -d {bundle-loc}