First of all, the API full name (Application Programming Interface, application programming interface) is some predefined functions, or the convention of connecting different components of a software system. The purpose is to provide applications and developers with the ability to access a set of routines based on certain software or hardware without having to access the source code or understand the details of the internal working mechanism.
API definition
For many product Xiaobai or job seekers, API is a professional term in the field of product and R & D. you may have touched the concept of API in the article or PRD.
In fact, the application of interface has been very extensive and mature. This concept is mainly active in the connection and docking of various systems within the company and the scene of cooperation between companies. If you can read this article carefully, I believe you will have a deeper understanding of API interface, even more than 90% of Xiaobai and job seekers.
Contents
- What is the API API interface of the game?
- Why do we need the API API interface?
- The core of API API interface
The core of API API interface
Let’s understand the API using a common mathematical formula, such as y=x+2, when x=2, y=4, right?
At this time, we call y = x + 2 as the interface, x = 2 as the parameter, y = 4 as the return result. The function of this interface is to add 2 to the number we input (Note: Here you can find that the interface itself has logic).

In analogy, let’s understand a common scenario. For example, there is an interface that can convert latitude and longitude into a city. When I input longitude is 55° and latitude is 88°, the interface uses its own logical operation and returns the result to tell me: Hangzhou City.
In this way, you can clearly understand the official interpretation of Baidu Encyclopedia. The interface is a predefined function logic, which is used by other systems to request and return results.
2、 Why do we need game API?
Background: our business system involves many aspects. If we want a company or a system to finish all the business, is the workload too heavy? And if other systems or companies have better operational logic, we can consider using interfaces for development when designing functions.
Core requirements: using existing interfaces can reduce development costs and shorten development costs.
For example: for example, I am an app that makes games. Now I need to show the functions of games on my page. For our company, the cost of new development is too high. Then we can access the API provided by the open platform of ngapi interface provider. In this way, we only need to apply for API interface account opening, deploy and call ngapi interface API, so we can quickly launch a rich game platform on our page.

3、 The core of API
For Xiaobai, at first glance, the API documents may be confused - where to look, how to look, and what is the problem in front of him.
In fact, for product managers, we should pay more attention to what kind of API services this company can provide. For example, I know that Gaud can provide map API and route planning API, so that we can think of calling their services or references in our design functions and work.
Therefore, if you don’t understand the product, you don’t have to worry too much. You will also have a deeper understanding in your future work, because understanding is not complicated. The following are the core points of the API interface, and all the instructions and documents are inseparable from these 5 core points.
The following descriptions are all taken as an example by WeChat open platform. At the end of the article, there are addresses of various open platforms, so you can learn when you have time. OK, without further ado, let's set up a scenario now.
We now have an app that requires users to set up the wechat payment API to complete the purchase. Please enter the scene automatically and regard yourself as a product manager.
1. Interface address
Now, users click to pay. We need to tell wechat that we need to set up your cashier! But where to tell? This requires the interface address, which is equivalent to transferring the specified data to the wechat link.
A link address is not a page we understand, you can understand it is a phone number, Xiaobai people want to change this concept.
At this time, we can see that the interface document tells us that the link is as follows. Then we have already called wechat.

2. Request parameters (message)
Now we need to tell wechat that you want to call the cashier, right. Then we need to write it down. The message generated at this time is called a message, that is, what do you want to tell the content of this interface? Equivalent to the input x = 2 of the previous function.
Generally speaking, the format and content of the message are specified according to the interface document. For example, the following is the message requirements of wechat open platform for starting the cash register.

Let’s look at the first two parameters first. You are talking to WeChat now. Should you tell WeChat first, who are you? The WeChat document here tells you that you should use the application ID + merchant number to determine your identity. What does it mean?
For example, if you are a merchant, there are three apps a, B and C below, so wechat needs to know which merchant you are and which app below needs to use the cash register. This is very important. After wechat, you need to type the received money into the corresponding account and statistics.
Then let’s write these two sentences in the message:
- ≪ appid & gt; wx2421b1c4370ec43b & lt; / appid & gt; (my app ID is wx2421 ).
- ≪ MCH & ID & gt; 10000100 & lt; / MCH & ID & gt; (my merchant ID is 10000 ).
OK, now that wechat knows who you are, you need to tell wechat how much money you need to pay for you, right? The currency type and total amount are defined here, that is, what currency and how much money to collect.

Here you can see whether the currency type must be filled in, that is to say, you can also not tell what the wechat payment currency type is, because he noted that the default is RMB later.
OK, let's write two messages
- ≪ Free U type & gt; CNY & lt; / Free U type & gt
- ≪ total fee & gt; 1 & lt; / total fee & gt

Okay, now WeChat knows who you are and how much money you have to charge. Then WeChat Pay will tell you the results of the collection, because you have to know that the user has successfully paid before continuing to ship, service, etc. So here we use the notification address, which is to tell WeChat, and when the matter is done, he will tell you the payment result. Then let's write the address:
<notify_url>http://wxpay.wxutil.com/pub_v2/pay/notify.v2.php</notify_url>
3. Return results
Just now, wechat payment has gone to collect money. Now he will tell us the result in the notice address we left. There are only two results: successful collection? Collection unsuccessful?
(1) Success
It went very smoothly. Now the user has successfully paid, and WeChat has also told us the successful news, and it also told us some information about the user's payment.
This is the information that wechat tells us after the payment is successful.

App appid, merchant No.: tell you which merchant and which appid transaction I successfully deducted.
Business result: success or failure
(2) Failure
In product design, we often pay attention to failure. When collection fails, wechat will also tell you the reasons for failure, as shown in the figure below. There are many reasons for failure. When designing, we often analyze the reasons for each failure, and design pages and user prompts for the reasons of each failure to ensure that users can understand.

The above is the understanding of the basic operation mode of API. Next, I will continue to update some more in-depth and detailed key elements of API, such as request mode / signature / encryption and decryption, etc.