Discover API Proxies with Google Apigee: A Practical Demo

Sumit K
Google Cloud - Community
10 min readNov 22, 2023

In my previous article, we delved into the intricacies of APIs, unraveling their significance and the mechanics of client-API interactions. We witnessed how APIs are revolutionizing the modern application landscape. Subsequently, we examined the realm of API management services, highlighting Google Apigee’s prominence amidst many players.

Additionally, we delved into the overview and architecture of Apigee’s proxy architecture, culminating in a comprehensive understanding of API proxies, API policies, API products, and API Apps. Now, we embark on a practical journey to implement an API proxy and access it seamlessly from the internet.

Before you can set up and deploy API proxies with Apigee, you must meet the following prerequisites:

  1. Create a Google Cloud project if you have not done so already.
  2. Select the Project and search for Apigee in the search bar or you can also find it in the Navigation Menu under the “Integration Service” as depicted.

3. Choose the Evaluation plan for the Apigee free trial for 60 days or as-you-go plan. for this tutorial, I will go with the Evaluation Plan. The Apigee provisioning wizard displays the Set up Apigee Evaluation page. As you complete each step, the EDIT icon will be displayed by the next step.

Let’s first understand these three steps one by one.

3.1 Enable APIs: This will enable required APIs in your project such as Apigee API, Compute Engine, Networking API, etc

Enable APIs

3.2 Networking: Networking automates the private connectivity

Set up networking for your local Virtual Private Cloud (VPC).

  1. Click EDIT next to Networking.
  2. The Set up networking pane displays:
  3. Select a network from the Authorized Network drop-down list. For most eval orgs, you will select default
Networking

3.3 Apigee evaluation organization

Create an Apigee eval organization.

  1. Click EDIT next to Apigee evaluation organization.
  2. The Create an Apigee evaluation organization pane displays:
  3. Select an analytics hosting region and a runtime location.In my case I will go with “New Delhi” Region. Click PROVISION.

Note: This process can take up to 45 minutes.

When it is done, a check will display next to the Apigee evaluation organization step and the Access routing step will be available.

Apigee evaluation organization setup

3.4 Access routing

In this step, you choose whether to expose your new cluster to external requests or to keep it private (and only allow requests from within your VPC). How you access API proxies depends on whether you decide to allow external requests or restrict requests to internal only.

Now, I want to allow external access to my API Proxy. Let’s configure this step.

  1. Click create and EDIT next to Access routing.
  2. Select Enable Internet access from the Configure access panel. The wizard displays additional options for configuring the instance:
configure routing for external access in the Apigee provisioning wizard

3. For the domain setting, enter a valid DNS name that you own, or choose to use a wildcard DNS service, such as nip.io. If you choose the wildcard service, a static external IP address is reserved for you. The wildcard option is easy to use, but is only recommended for testing purposes.

4. If you are using a wildcard DNS service, just note that a Google-managed certificate will be created for the domain.

5. Click SET ACCESS.

When Apigee finishes setting up your runtime’s access, you’ll notice that there is a blue check mark next to all steps in the wizard:

6. When Apigee finishes setting up your runtime’s access, you’ll notice that there is a blue check mark next to all steps in the wizard. Click CONTINUE.

You have now completed the steps to configure external internet access to API proxies.

Now, Let’s verify the Load balancer components that are created during the Access Routing. Go to Network Service →Load Balancing. Here you will see the Load balancer details along with the MIGs, SSL certificate and Static Public IP

How to View Organization Details

Finally, open the Apigee UI to view details about your organization

  1. Click OPEN APIGEE CONSOLE to open the Apigee UI.
  2. Make sure the project you just created is selected in the Apigee UI. For example:

3. Click settings admin to see the configuration of your org:

4. Click codeDevelop > API Proxies. Apigee created an API proxy called hello-world for you when you provisioned the eval org.

Deleting an evaluation organization

To delete (or deprovision) an eval organization, use the gcloud alpha apigee organizations delete command.

Build your first API proxy

Overview: Apigee is a platform for developing and managing API proxies.An API proxy is your interface to developers that want to use your backend services. Rather than having them consume those services directly, they access an Apigee API proxy that you create. With a proxy, you can provide value-added features such as:

  • Security
  • Rate limiting
  • Quotas
  • Caching & persistence
  • Analytics
  • Transformations
  • CORS
  • Fault handling
  • And so much more…

Introducing the new Apigee UI:

Apigee is introducing a new version of the UI, which is part of the Google Cloud Console. For now, both the new and the classic version of the UI are available. However, the classic version will be removed in a future release.

To build and deploy your first API proxy:

  1. Create an API proxy using the Apigee UI. You’ll connect your proxy to a mock endpoint so you can see how it works.
  2. Deploy your API proxy to an environment.
  3. Test your API proxy to make sure you’re on track.
  4. Change the target endpoint so your policy has more interesting data to play with.
  5. Add a policy to convert the response from XML to JSON. Policies are at the heart of your proxy’s request-response flow.

Let’s begin with the First Demo

  1. Go To the Apigee Console
  2. In the left navigation pane, click Proxy development > API Proxies. By default, Google Apigee has created an API proxy for with the name “hello-world” for quick testing.

3. Lets call it but wait a minute !!! how do you call it. What endpoint is required to access your hello-world proxy. If you don’t know the environment group hostname, you can find it as follows: In the Apigee UI, select Admin > Environments > Groups.

Look for a row displaying the environment in which your proxy is deployed. For example, if the environment is test-1, the row might appear as shown below.

If the environment group hostname was set up during provisioning using a wildcard service, such as nip.io, you can call the proxy without having a DNS entry configured. For example:

4. Let’s Grab this wildcard DNS and access it from your browser by adding the proxy as follows. A successful call to the proxy returns the following output:

With Browser

Let’s begin with the Second Demo

Step 1: Create an API proxy

Over Here, we will create our own custom simple API proxy. Please follow along the steps below:

  1. Open the Apigee UI in Cloud console in a browser
  2. In the left navigation pane, click Proxy development > API Proxies.
  3. In the Create a proxy pane, under Proxy template, select Reverse proxy (Most common).
  4. In the API Proxies pane, click + Create.
  5. Under Proxy details, enter the following:

Proxy name: Enter my-proxy

Base Path: proxy name such as /my-proxy

Description (Optional):

Target (Existing API):Enter https://mocktarget.apigee.net The mocktarget service is hosted at Apigee and returns simple data. It requires no API key or access token.

Click Next and Click Create.

Apigee creates the new proxy and displays a summary of the proxy details in the Proxy summary pane.The Deployments section is empty because the proxy has not yet been deployed.

Proxy Summary Page

Step 2: Deploy an API proxy

  1. After creating a new proxy, you must deploy it
Deploy API Proxy

2. To deploy your changes, first click Deploy to display the Deploy dialog. Enter the Revision and Environment. Leave the service Account blank for now.

Deploy with revision

3. When the proxy is deployed, you will see a green icon

deployment status completed

Step 3: Call an API proxy

You can call your proxy is the same way that we have done before on the hello-world proxy. https://34.117.54.224.nip.io/my-proxy

A successful call to the proxy returns the following output:

Step 4: Change the target endpoint

Let’s say you want to change the target endpoint from https://mocktarget.apigee.net to something else. Let’s say my Medium profile :) To do that:

  1. In the proxies list, select the proxy my-proxy →Click on Develop →Display the Develop View. Below the visual edit or, the XML code for the target endpoint is displayed in the text editor. The new URL is shown below in bold text.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<TargetEndpoint name="default">
<Description/>
<FaultRules/>
<PreFlow name="PreFlow">
<Request/>
<Response/>
</PreFlow>
<PostFlow name="PostFlow">
<Request/>
<Response/>
</PostFlow>
<Flows/>
<HTTPTargetConnection>
<Properties/>
<URL>https://medium.com/@lyfedge799</URL> #This is your new target endpoint
</HTTPTargetConnection>
</TargetEndpoint>

2. Click the arrow next to Save at the top right of the Proxy Editor, and select Save as new revision, and then deploy your changes, click Deploy.

3. In the Deploy dialog, select the revision and environment in which to deploy, and click Deploy.

Deploy proxy with next revision

Test the proxy:

Hit this Endpoint again: https://34.117.54.224.nip.io/my-proxy

A successful call to the proxy returns the following output:

API Product:

As an API provider, you create API products to bundle your APIs and make them available to app developers for consumption. You can think of API products as your product line.

  1. Go to the Publish field and create API Products. Add name, description, display name, and add environment which was created.

Attach the API product with your Proxy which is my-proxy in our case.

finally, click on SAVE

Create API Product

2. Now, create a Portal for the API Product. Portals are not yet implemented in the Cloud Console so you have to switch to the Classis Apigee UI.

Create Portal

3. Now, next is we need to have a portal for our API product. select the API catalog from your portal as follows.

API Catalog

4. Click in the API Catalog from the drop-down

4. Next, Click on the + icon to add an API to your product (my-product)

5. Now, In the API portal Dashboard, click on published and if you want, you can add a Title, Description, and image. I have added the image.

6. Click on APIs to see your product details (my-product). Click on the Live portal to see the view.

7. now, click on the APIs to see your product overview

Deleting an API product

Before you can delete an API product, you must unregister/unassociated any developer apps associated with the product. You can do so by either deleting the apps

If you are using the classic Apigee UI: Select Publish > API Products.

  1. Select Publish > API Products.
  2. Open the Actions menu in the row of the product to delete and select Delete.
  3. After you confirm the delete operation, the deletion takes effect within a short period (approximately five minutes).

4. To Delete the Portal: Go to the Portal and simply Delete it after you confirm the delete operations

Thank you for Reading!!! We’ve covered the basics of how to create a proxy, configure it to route traffic to a backend service, and publish it to an API product and portal. This is just the beginning of what you can achieve with Apigee.

Stay tuned as we embark on this exciting exploration of API policies along with a deeper look into Security and Authorization where we’ll unravel their intricacies and discover their transformative impact on your API management strategy.

Book a call for consulting/assistance: https://topmate.io/sumit_kumar40

--

--

Sumit K
Google Cloud - Community

Humanity is the quality that we lack so much in real life, An Abide leaner, Cloud Architect⛅️, Love DevOps,,GDE,Proud Hindu 🕉️