what is api

藏色散人
Release: 2023-01-06 17:33:24
Original
210713 people have browsed it

api's full name is "Application Programming Interface", which means "Application Programming Interface" in Chinese. It is a set of predefined functions that provide applications and developers with access to a set of routines based on certain software or hardware. capabilities without having to access the source code or understand the details of the inner workings.

what is api

The operating environment of this tutorial: Windows 7 system, Dell G3 computer.

API (Application Programming Interface, Application Programming Interface) are predefined functions that are designed to provide applications and developers with the ability to access a set of routines based on certain software or hardware without having to access Source code, or understanding the details of the inner workings

Application Programming Interface

Think of it like an API in a restaurant menu. The menu provides a list of dishes you can order, along with a description of each dish. When you specify the menu items you want, the restaurant's kitchen can do the work and serve you some finished dishes. You don't know exactly how the restaurant prepares the food, and you really don't need to.

Similarly, an API lists a series of operations that developers can use, along with a description of what they do. Developers don't necessarily need to know how to build an operating system and display the Save As dialog box. They just need to know that it can be used in their applications.

This isn't a perfect analogy, as the developers would probably have to provide their own data to the API to get the results, so maybe it's more like a fancy restaurant where you could provide some of your own ingredients that the kitchen will use .

But its accuracy is very accurate. APIs allow developers to save time by leveraging the platform's implementation to do the nitty-gritty work. This helps reduce the amount of code developers need to create and also helps create greater consistency between applications on the same platform. APIs can control access to hardware and software resources.

API makes life easier for developers

Let’s say you want to develop an app for iPhone. Apple's iOS operating system provides a wealth of APIs - just like other operating systems do - to make it easier for you.

For example, if you want to embed a web browser to display one or more web pages, you don't need to write your own web browser from scratch for your application. You can use the WKWebView API to embed WebKit (Safari) browser objects in your application.

If you want to capture photos or videos from your iPhone's camera, you don't need to write your own camera interface. You can embed the iPhone's built-in camera in your app using the Camera API. If no API exists to make this easy, application developers must create their own camera software and interpret the input from the camera hardware. But Apple's operating system developers have done all the hard work so developers can embed the camera using the camera API and then go on to build their apps. And, when Apple improves the camera API, all apps that rely on it will automatically take advantage of the improvement.

This works on every platform. For example, do you want to create a dialog box on Windows? There is an API. Want to support fingerprint authentication on Android? There's also an API so you don't have to test every different Android manufacturer's fingerprint sensor. Developers don't have to reinvent the wheel over and over again.

API controls access to resources

API is also used to control access to hardware devices and software features that applications do not necessarily have permission to use. . This is why APIs often play an important role in security.

For example, if you have visited a website and see a message in your browser from the website asking to see your exact location, the website will try to use the Geolocation API in your web browser. Web browsers expose such APIs to give web developers easy access to your location - they can ask "Where are you?" and the browser can easily access GPS or nearby Wi-Fi networks to find your physical location.

what is api

# However, the browser also exposes this information through the API because it can control access to it. When a website wants to access your exact physical location, the only way they can get it is through the Location API. And, when a website attempts to use it, you - the user - can choose to allow or deny the request. The only way to access hardware resources such as a GPS sensor is through the API, so the browser can control access to the hardware and limit what applications can do.

The same principle is used in modern mobile operating systems such as iOS and Android, where mobile applications have permissions that can be enforced by controlling access to APIs. For example, if a developer attempts to access the camera through the Camera API, the permission request can be denied and the app cannot access the device's camera.

File systems that use permissions (as on Windows, Mac, and Linux) have permissions enforced by the file system API. Typical applications do not have direct access to the original physical hard drive. Instead, applications must access files through the API.

API is used for communication between services

API is also used for various other reasons. For example, if you've ever seen an embedded Google Map object on a website, the website uses the Google Maps API to embed the map. Google exposes such APIs to these web developers, who can then use the API to populate complex objects on their websites. If such an API didn't exist, developers might have to create their own maps and provide their own map data just to put a small interactive map on a website.

And, since it's an API, Google can control access to Google Maps on third-party sites, ensuring they use it in a consistent manner rather than trying to embed a frame that displays Google Maps on the site.

This applies to many different online services. There are APIs you can use to request text translations from Google Translate, or embed Facebook comments or tweets from Twitter on your website.

The OAuth standard also defines a number of APIs that allow you to log into websites with other services, for example, using your Facebook, Google, or Twitter account to log into a new website, not just the website you created A new user account. APIs are standard contracts that define how developers communicate with a service, and the type of output the developer should receive.

Unless you are a developer, you don't need to know what an API is. However, if you see a software platform or service adding new APIs for various hardware or services, it should be easier for developers to take advantage of these capabilities.

The above is the detailed content of what is api. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!