Interactions between mobile apps and Web/cloud services are common, from data retrieval to user authorization and management. If you want to ensure the normal and efficient operation of the App, reduce development costs, and simplify application code, creating an API is essential. This article describes the design skills of the 10 major mobile APIs.
It is common for a mobile App to have a conversation with a Web/cloud-based service. The simplest thing is to retrieve data, but it may also include sending data, user authorization, and management. This verifies the importance of creating APIs for mobile apps. Therefore, we have summarized the design skills of the 10 major mobile APIs.
1. API Version Control
At any time, it is inevitable for developers to modify APIs to ensure the normal operation of applications. They may only add, delete, or perform other operations on some functions. In this case, you have to suspend the use of the API, or allow the application in use to have a clear understanding of the behavior and response type to be returned.
An API is like an agreement between your application backend and the application that uses it. Without proper version control, one party can change the agreement without the other party's knowledge. Then, you will be in a very dangerous situation. Support for multiple API versions allows users who do not upgrade their applications in time to continue using the API. The latest version of the App allows you to see all the changes to the latest API.
In a mobile App, the importance of API version control is obvious. Without API version control, modifying the API can easily stop the App running, and the consequences will make you regret it in a bid.
2. The returned data should not exceed the required
To a certain extent, the amount of data sent between the application and the server will affect the time for sending the request and its response. The impact is not only the time it takes for the user to focus on loading the page, but also the traffic it takes to load the page.
3. compress the sent and received data
In addition to not returning data that exceeds your needs, compressing the sent and received data allows you to get twice the result with half the effort in speed and data transmission and experience more benefits.
4. resolutely Delete unnecessary steps/requests
API design is common to provide separate discrete steps, but this reflects how the service is used. Therefore, in most cases, these discrete steps are not the most effective method for executing mobile apps.
Let's take a very simple example. The user has provided valid authentication information and logged on before sending the request data. This may be reasonable. We can consider it as two separate steps:
- The provided authentication information is valid. The API responds to a session token.
- When a data request is sent, the session token passes.
But in fact, this operation does not need to be repeated. When a single request is sent, the data and session token are returned simultaneously through authentication information and related data details.
The advantage of this is that when a user uses an App, the response speed is faster and the traffic usage is less. For developers, this can make the application code simpler. In this way, both development costs and maintenance costs can be reduced.
5. Merge requests and responses
In addition to multiple requests sent during authentication or application startup, multiple requests may be sent to retrieve all data on a single page or view of the application. Creating a single request for all the data required by the page is much faster than multiple requests, and the cost is also lower. The speed and cost are the two main factors that users should first consider when using applications.
In addition, merging requests and responses can make the application code simpler, especially when multiple requests are processed but failed. If all requests are merged or merged to zero, then many exceptions become very simple and easy to process.
6. Top priority: Security
Security is a complex problem that may be exposed at any time in the hidden crisis, which makes it difficult for apps to respond to security issues in a timely manner.
Therefore, you must always consider the following:
- Ensure absolute data security during transmission;
- Secure data waiting for transmission;
- Improper or unauthorized use of APIS;
- Potential Consequences of malicious or unexpected data.
7. plan and execute your cache policy carefully
If the return value of your application API does not change frequently, you must implement an appropriate Cache Policy. This may involve storing data in the memory instead of repeatedly reading data from the hard disk. In addition, it may affect the cache performance of the HTTP part.
If you cache the service on the server, make sure that you can forcibly stop the service when it goes down.
In addition to the server side, the application client that uses the API must also ensure that appropriate cache policies are implemented. If you request to call the latest data, you can save some time and resources. If you avoid calling during initialization, it will save more time and resources.
8. Integrated Analysis
Analysis is a very important part of understanding how an App is used. During normal use of the App, in addition to sending data requests, it is common to make an analysis service. For example, if an application tries to call a service to refresh the page and the user navigating to the page, redundancy will occur when a separate tracing/analysis is added to the navigation.
In the original period, using APIs can serve as an indicator of App usage and time. Compared with the rich analysis tools and frameworks, they provide very detailed information about user interaction with the App. If you are between the two, think carefully about how to perform integrated analysis, or send an additional or redundant call just to track application usage.
9. What is the name? Please think carefully!
Naming reflects the methods, objects, attributes, and parameters that you grant to the API, which greatly affects the understanding of API users. When creating an API, No matter what term or term the user first thinks of, it is very attractive in itself. Like all code, a large part of the reason you use it is how the API is understood and expected to behave. If the name is not good, it will be confusing. Confusion leads to errors, errors lead to bugs, and bugs lead to delays and increased support costs. So spend more time on naming!
10. Do not forget your privacy protection policies and responsibilities
If your application needs to capture user data or log on to the server and record requests, you must develop a privacy protection policy, to describe how you use the data information. In addition, you must think about how to store and protect such data, especially if it is personal information or is related to children.