Skip to main content

Version: 3.2.14.6

Launch Your First API

This tutorial describes launching and validating a simple API on API7 Gateway. You will complete the following steps:

  1. Create a Published Service with a Route and an Upstream that points to httpbin upstream.
  2. Validate the created API by sending a request.

Prerequisites

  1. Install API7 Enterprise.
  2. Have at least one gateway instance in your gateway group.

Start a Sample Upstream Service

If you are running API7 on Kubernetes, you will be deploying an httpbin application to your cluster in this section as the sample upstream service. Otherwise, skip to the next section where you will be using the hosted httpbin application as the upstream.

Start a sample httpbin application:

kubectl run httpbin --image kennethreitz/httpbin --port 80

You should see a pod/httpbin created response.

Expose the application's port 80 through a service:

kubectl expose pod httpbin --port 80

You should see a service/httpbin exposed response.

Create Service and Route

Create a Service

  1. Select Published Services under your gateway group from the side navigation bar and then click Add Service.
  2. Select Add Manually.
  3. From the Add Service dialog box, do the following:
    • In the Name field, enter httpbin.
    • In the Service Type field, choose HTTP (Layer 7 Proxy).
    • In the Upstream Scheme field, choose HTTP.
    • In the How to find the upstream field, choose Use Nodes.
    • Click Add Node.
    • From the Add Node dialog box, do the following:
      • In the Host field, enter httpbin.org.
      • In the Port field, enter 80.
      • In the Weight field, enter 100.
  4. Click Add. This will create a new service in the 'No Version' state.

Create a Route

  1. Click the service that you just created in the previous step, and then click Add Route.
  2. From the Add Route dialog box, do the following:
    • In the Name field, enter get-ip.
    • In the Path field, enter /ip.
    • In the Methods field, choose GET.
    • Click Add.

Below is an interactive demo that provides a hands-on introduction to creating no-version services. You will better understand how to use it in API7 Enterprise by clicking and following the steps.

Validate the API

Send a request to the route:

curl "http://127.0.0.1:9080/ip"

You should see the following response:

{
"origin": "127.0.0.1"
}

And that’s it. You have your first API running now.

Add APIs by Importing OpenAPI

You can also add APIs by importing OpenAPI 3.0 specification.

Create a Service

  1. Select Published Services under your gateway group from the side navigation bar and then click Add Service.
  2. Select Import OpenAPI.
  3. From the Add Service dialog box, do the following:
    • In the OpenAPI 3.0 Specification field, upload httpbin.yaml file.
    • In the Upstream Scheme and Service Type fields, keep the default settings HTTP.
    • In the How to find the upstream field, keep the default setting Use Nodes.
    • Click Add Node.
    • From the Add Node dialog box, do the following:
      • In the Host field, enter httpbin.org.
      • In the Port field, enter 80.
      • In the Weight field, enter 100.
    • Click Next.
  4. Click Add. This will create a new service in the 'No Version' state. The basic information, labels are imported, and all paths in the openapi file are transformed to routes in the service.

Below is an interactive demo that provides a hands-on introduction to adding services by importing OpenAPI. You will better understand how to use it in API7 Enterprise by clicking and following the steps.

Additional Resources


API7.ai Logo

API Management for Modern Architectures with Edge, API Gateway, Kubernetes, and Service Mesh.

Product

API7 Cloud

SOC2 Type IIISO 27001HIPAAGDPRRed Herring

Copyright © APISEVEN PTE. LTD 2019 – 2024. Apache, Apache APISIX, APISIX, and associated open source project names are trademarks of the

Apache Software Foundation