Help Center> > Best Practices> Querying Mobile Number Home Locations

Querying Mobile Number Home Locations

Updated at: Jun 18, 2019 15:26

Overview

The best practice for HUAWEI CLOUD API Gateway guides you through API opening and calling.

This chapter provides guidance on opening an API for a mobile number location lookup service and publishing the API in the RELEASE environment. It also presents instructions on binding a request throttling policy to the API to ensure continuous, stable API services.

What Is API Gateway

API Gateway is a high-performance, high-availability, and high-security API hosting service that helps enterprises to build, manage, and deploy APIs at any scale.

What You Can Do with API Gateway

  • Easily create, manage, and deploy APIs at any scale.
  • Configure flexible request throttling policies to ensure continuous, stable API services.
  • Monitor API services in terms of multiple metrics.

Preparing the Environment

Before using API Gateway to open the mobile number location lookup service, obtain a username and password for logging in to the HUAWEI CLOUD console. The username must have completed real-name authentication. In addition, collect required information according to Table 1.

Table 1 Environment information

Item

Example

API group name

PhoneNumberGroup

API name

PhoneNumber

Authentication mode

None

Request path

/test/{phoneNumber}

Backend address

apigdemo.myhuaweicloud.com

Backend request path

/api/mobile/{phoneNumber}

Environment

RELEASE

Request throttling policy name

PhoneNumberThrottling

Throttling period

1 minute

API maximum

20

User maximum

10

Opening an API

  1. Log in to the HUAWEI CLOUD management console, select a region in the upper left corner, and choose Service List > Application > API Gateway.

  2. Create an API group. Figure 1 highlights this area.

    Figure 1 Creating an API group
    Figure 2 Prompt message

  3. Create an API.

    1. Set the basic information of the API, as shown in Figure 4).

      For details about the parameters, see the API Gateway User Guide.

      Figure 3 API list
      Figure 4 Setting basic API information
    2. On the Define API Request page, set the API request information.

      For details about the parameters, see the API Gateway User Guide.

    3. On the Define Backend Request page, set the backend request information.

      For details about the parameters, see the API Gateway User Guide.

    4. On the Define Response page, set the success response shown in the following figure.

    5. Click Finish.

  4. Debug the API.

    Figure 5 API list
    Figure 6 Debugging the API

  5. Publish the API.

    Figure 7 API list
    Figure 8 Publishing the API

Calling the API

  1. In the API list, click the created API, and then copy the API URL.

    Figure 9 API list
    Figure 10 Copying the URL

  2. Paste the URL of the API on the address bar of a browser, and replace {phoneNumber} with the mobile number to be queried.

    Information on the mobile number's origin will be returned if the API is called successfully.

Binding a Request Throttling Policy

  1. Create a request throttling policy.

  2. Bind the request throttling policy to the API.

  3. Call the API by copying its URL to a browser. For details, see Calling the API.

    If the API is called more than 20 times within one minute, an error will be reported.

Viewing Metrics

  1. On the APIs page, click the API to display the details page.

  2. On the Monitoring tab page, view the API metrics, including requests, latency, data traffic, and errors.

  3. Click View More Metrics to view complete metrics on the Cloud Eye console.

    NOTE:

    Metrics data is retained for two days. For longer retention periods, save data to an OBS bucket.

Did you find this page helpful?

Submit successfully!

Thank you for your feedback. Your feedback helps make our documentation better.

Failed to submit the feedback. Please try again later.

Which of the following issues have you encountered?







Please complete at least one feedback item.

Content most length 200 character

Content is empty.

OK Cancel