Skip to main content

Setup Your API Proxy

Let's put a gateway over this sample e-commerce API at https://ecommerce-api.zuplo.io with a Zuplo gateway and add rate limiting. Quickly take a look at the API by opening this URL in your browser: https://ecommerce-api.zuplo.io/products/10000

You can also 'Zup It!' to create an instant copy of this project with all the code complete for you: Zup it!

1: Routes Setup

Open the routes.json file and add a new route.

Untitled

Set the version to be v1 and the path of the new route to be /products/:productId.

Untitled

2: Rewrite Handler

Set the mode of the Request Handler to be URL Rewrite and the rewrite path to be https://ecommerce-api.zuplo.io/products/${params.productId}. Notice that this appends the productId token to the outbound URL.

Untitled

3: Test

Use the route tester at the top of the screen to check your re-write logic. Open the route tester (top right) and set the path to be /v1/products/10000. Verify that your route was matched and the URL re-written appropriately.

Untitled

Untitled

4: Rate Limiting

Expand the Policies section and click the Add Policy button under request. Search for and click the Rate Limiting policy.

Rate Limiting

Accept the default configuration. Note how it's set to allow only 2 requests every 20s for a given IP address.

5: Test Rate Limiting

Invoke your API using the Test Console. Click on the lightning tab and select the first file. Change the path to /v1/products/10000 and hit Test.

Untitled

Try quickly testing it a few more time to see the rate limiter kick in - you'll get a 429 response, "Too many requests".

Congratulations, you completed a quickstart

Try another quickstart (above) for more awesome.

Why not try one of the other getting started guides (above) or some of the examples in our documentation: