Launch Your First API
This tutorial describes launching and validating a simple API on API7 Enterprise. You will complete the following steps:
- Create a Service with a Route and an Upstream that points to
httpbin.org
. - Publish the created service to the default Gateway Group.
- Validate the created API by sending a request.
Prerequisites
- Install API7 Enterprise.
- Obtain a user account with Super Admin or API Provider role.
- Have at least one Gateway Instance in your default gateway group.
Create a Service
- Select Services from the side navigation bar and then click Add Service.
- Select Add Manually.
- From the Add Service dialog box, do the following:
- In the Name field, enter
httpbin
. - In the Upstream Scheme field, choose
HTTP
.
- In the Name field, enter
- Click Add.
Create a Route
- Click the service that you just created in the previous step, and then click Add Route.
- From the Add Route dialog box, do the following:
- In the Name field, enter
getting-started-ip
. - In the Path field, enter
/ip
. - In the Methods field, choose
GET
.
- In the Name field, enter
- Click Add.
Publish the Service
- Select Services from the side navigation bar and then click Publish Now for the
httpbin
service. - Choose the
default
gateway group and then click Next. - From the dialog box, do the following:
- In the New Version field, enter
1.0.0
. - In the How to find the upstream field, choose
Use Nodes
.
- In the New Version field, enter
- 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, use the default value
100
.
- In the Host field, enter
- Click Add.
- Confirm the service information, then click Publish.
Use ADC to Create the API
Alternatively, use ADC to configure API7 Enterprise declaratively instead of the dashboard. The complete configuration is below:
adc.yaml
services:
- name: httpbin
upstream:
name: default
scheme: http
nodes:
- host: httpbin.org
port: 80
weight: 100
routes:
- uris:
- /ip
name: getting-started-ip
methods:
- GET
Synchronize the configuration to API7 Enterprise:
adc sync -f adc.yaml
Validate the API
Make an API request to validate the API:
curl "http://127.0.0.1:9080/ip"
You should see the following output:
{
"origin": "127.0.0.1"
}
And that’s it. You have your first API running now.