应用程序编程接口大全

Do apps like Uber, Pokémon Go and Zomato build their own maps to show where available cars are, help the user find wild Pokémon, or display nearby restaurants. Do these apps need to spend thousands of person-hours making their own maps? We all know, that the answer is no. They embed a Google Map in their app. Uber app draws the route you’ll take on a Google Map and calculates the approximate time it’ll take to get there.

诸如Uber,PokémonGo和Zomato之类的应用程序会构建自己的地图以显示可用车的位置,帮助用户查找野生的Pokémon或显示附近的餐馆。 这些应用是否需要花费数千个人工时制作自己的地图? 众所周知,答案是否定的。 他们在自己的应用程序中嵌入了Google地图。 Uber应用程式会在Google Map上绘制您要走的路线,并计算到达那里所需的大概时间。

Google lets you include a small snippet of code in your app to draw a Google Map, and it provides other snippets of code to let you draw on the maps, calculate driving directions between points on the map, and even find out the speed limit for a particular road. All of these tools are cheap or even free. These tools are big win for developers; they can use the technology which took Google years to perfect with just a small amount of code. There’s no need to reinvent the wheel!

Google允许您在应用程序中包含一小段代码以绘制Google Map,并提供其他代码段以使您可以在地图上绘制,计算地图上各点之间的行驶方向,甚至可以找到速度限制一条特定的道路。 所有这些工具都很便宜,甚至免费。 这些工具对开发人员来说是巨大的胜利。 他们只需使用少量代码就可以使用Google花费了数年时间完善的技术。 无需重新发明轮子!

These snippets of code that let you borrow another app’s functionality or data are called APIs, or Application Programming Interfaces. In short, APIs let apps talk to each other.

这些可让您借用其他应用程序功能或数据的代码段称为API或应用程序编程接口。 简而言之,API使应用程序可以相互通信。

那么,什么是API? 就像菜单。 (So, what is an API? It’s like a Menu.)

In another analogy, you’re a program and the restaurants are programs that you want to interact with. To receive what you want (food) from the other program (restaurant), you need to make a request (place an order) in a specific way (defined by the menu).

另一个比喻,您是一个程序,而餐厅是您要与之交互的程序。 要从其他程序(餐厅)接收想要的东西(食物),您需要以特定方式(由菜单定义)发出请求(下订单)。

APIs are like menus. Menus define a list of dishes and, when someone orders one of those dishes, the restaurant does a bunch of stuff and then sends the requested dish back. APIs define a list of commands and, when a program uses one of those commands, the other program does a bunch of stuff and then sends back what was requested by that command (usually some kind of data).

API就像菜单一样。 菜单定义了菜肴列表,当有人订购其中一种菜肴时,餐厅会做很多事情,然后将请求的菜肴发回。 API定义了一个命令列表,当一个程序使用这些命令中的一个时,另一个程序会执行很多操作,然后将该命令所请求的内容(通常是某种数据)发送回去。

It’s important to note that food ordering analogy isn’t perfect. When you order food, there are many variations you could use to get the same result. But programs aren’t as smart and flexible as humans. When making a request to another program, the request has to be formatted in a very specific way.

重要的是要注意,食品订购类比并不完美。 当您订购食物时,可以使用多种变体来获得相同的结果。 但是程序不像人类那样聪明和灵活。 向另一个程序发出请求时,必须以非常特定的方式格式化该请求。

If restaurants were like programs, saying “House Burger, medium-rare, no pickles, replace the fries with coleslaw” would get you your food but saying “may I please have the House Burger cooked medium-rare with coleslaw instead of fries and no pickles on the burger” would not. The restaurant wouldn’t understand what you’re asking because the request isn’t formatted correctly.

如果餐厅像节目一样,说“ House Burger,中度稀少,没有咸菜,用凉拌卷心菜代替薯条”会为您带来食物,但会说“请我让House Burger用凉拌卷心菜而不是薯条煮中等稀饭,在汉堡上腌制”不会。 餐厅无法理解您的要求,因为请求的格式不正确。

So APIs define a list of commands as well as the necessary format of those commands. When a company releases an API for their software, it means that they’ve basically told everyone: here is what you can get from our program and here is exactly how you have to ask to get it.

因此,API定义了命令列表以及这些命令的必要格式。 当公司为他们的软件发布API时,这意味着他们已经基本告诉所有人:这是您可以从我们的程序中获得的,这正是您要求获得它的方式。

API类型 (Types of APIs)

There are three main kinds of APIs:

API有三种主要类型:

The first kind of API lets one app ask another specialized app to solve a particular problem, like calculating driving directions, sending text messages, or translating sentences. It’s like how you could call a plumber or carpenter to fix problems around your house instead of trying to do it yourself. Here’s an example: apps like Uber can use PayPal’s Braintree API, which lets anyone use PayPal’s algorithm for processing credit card payments with just a few lines of code. It’s pain to write code yourself that sends emails or text messages — so when apps like Venmo need to send you confirmation emails or texts, they can just use a specialised API. And any app that lets you log in via Facebook or Google uses those websites’ APIs for verifying someone’s identity.

第一种API可让一个应用程序要求另一个专门的应用程序解决特定问题,例如计算行车路线,发送短信或翻译句子。 这就像您可以打电话给水管工或木匠来解决房屋周围的问题,而不是自己尝试解决。 这是一个示例:Uber等应用程序可以使用PayPal的Braintree API,该应用程序使任何人都可以使用PayPal的算法通过几行代码来处理信用卡付款。 自己编写发送电子邮件或短信的代码很痛苦—因此,当Venmo之类的应用需要向您发送确认电子邮件或短信时,他们只能使用专门的API。 任何允许您通过Facebook或Google登录的应用程序都使用这些网站的API来验证某人的身份。

The second type of API lets one app ask another app to hand over some interesting information, such as sports scores, recent Tweets, or today’s weather. It’s like calling the front desk at a hotel to learn which museums and restaurants they recommend. ESPN offers an API that lets you get rosters for every major-league sports team and scores for every game. New York’s subway system lets you track where trains are and predict when the next train will arrive at a station. And don’t worry, there’s even an API to get random images of cats.

第二种API使一个应用程序可以要求另一个应用程序提供一些有趣的信息,例如运动比分,最近的推文或今天的天气。 这就像给酒店的前台打电话,以了解他们推荐哪些博物馆和餐厅。 ESPN提供了一个API,可让您获得每个主要联赛运动队的花名册和每场比赛的得分。 纽约的地铁系统可让您跟踪火车的位置,并预测下一趟火车何时到达车站。 不用担心,甚至还有一个API可以获取猫的随机图像。

The final kind of APIs, lets developers access features of the device itself. Snapchat taps into your phone Camera’s API to zoom, focus, and snap photos. Google Maps itself uses your phone’s Geolocation API to figure out where in the world you are. Your phone even has sensors called accelerometers and gyroscopes, which fitness apps (and Pokémon Go) use to determine in which direction you’re walking and how fast you’re moving.

最后一种API 使开发人员可以访问设备本身的功能。 Snapchat可以利用手机相机的API来缩放,对焦和捕捉照片。 Google Maps本身使用手机的Geolocation API来确定您的位置。 您的手机甚至还具有称为加速度计和陀螺仪的传感器,健身应用程序(和PokémonGo)可使用这些传感器来确定您的行进方向和行进速度。

It’s worth noting that APIs aren’t perfect. Using an API makes app developers’ lives easier, but it also makes their apps dependent on the API. If PayPal’s Braintree payment API somehow stopped working, Uber would be unable to process payments — not great for their business. Still, a specialized company’s API will likely be more reliable than any similar feature that a non-specialist company could make themselves.

值得注意的是,API并不完美。 使用API​​可以简化应用程序开发人员的生活,但也可以使其应用程序依赖于API。 如果贝宝(PayPal)的Braintree付款API某种程度上停止工作,那么Uber将无法处理付款-这对他们的业务不利。 尽管如此,一家专业公司的API可能会比非专业公司自己制造的任何类似功能更可靠。

它们如何连接? (How are they connected?)

Let’s imagine that you are building an e-commerce application that takes orders from customers, verifies inventory and available credit, and ships them. The application consists of several components including the user interface, along with some backend services for checking credit, maintaining inventory and shipping orders.

假设您正在构建一个电子商务应用程序,该应用程序将接收来自客户的订单,验证库存和可用信贷,然后发货。 该应用程序由多个组件组成,包括用户界面以及一些用于检查信用,维护库存和运输订单的后端服务。

APIs and UI let you connect to the multiple backhand services which are built on these Mircroservices architecture (described in previous post).

API和UI使您可以连接到基于这些Mircroservices体系结构构建的多个反手服务(在上一篇文章中进行了介绍)。

Software Architecture
软件架构

Nimish Nama, IIM Calcutta (2019–21)

Nimish Nama,IIM加尔各答(2019-21)

翻译自: https://medium.com/tech-trek-for-rookies/application-programming-interface-101-43506fcd09a8

应用程序编程接口大全

http://www.taodudu.cc/news/show-4262111.html

相关文章:

  • Linux内核网络结构,和收发数据基本流程
  • Flutter之extension
  • 查看PostgreSQL数据库Extension
  • 设备扩展(DEVICE_EXTENSION)
  • PostgreSQL数据库扩展包——原理CreateExtension扩展控制文件解析
  • Chrome Extension 介绍
  • extension(类扩展)和 category(类别)
  • iOS开发中extension的用法(延展)
  • 《Hands-On Machine Learning with Scikit-Learn TensorFlow》读书笔记(二):端到端的机器学习
  • 【Linux】Linux input子系统之Input event codes
  • 怎么生成自动参考文献(简单 有图)
  • 论文参考文献GB/T 7714格式生成
  • 参考文献格式生成器(GB/T 7714-2015)
  • LaTex如何自动生成参考文献
  • 如何自动生成参考文献格式
  • LaTex 自动生成IEEE格式的参考文献
  • 写论文自动生成参考文献的方法
  • 参考文献格式自动生成器
  • vi编辑器详速查
  • 二极管总结
  • 解决数据库日期返回格式不是yyyy-MM-dd HH:mm:ss 的问题
  • CXF 处理yyyy-MM-dd HH:mm:ss日期失败
  • 中国荫罩对准器市场深度研究分析报告
  • Win 11 预览版虚拟机安装
  • HP-OMEN-暗夜精灵8,安装WIN10
  • 【手把手教安装】VM16 Pro安装Win10!!!
  • QT .pro文件详解
  • 单系统 台电x80pro_台电X80 Pro (E6E9)-双系统安装文件平板固件
  • 虹科干货 | 仅需3步!教你如何基于Windows系统操作使用RELY-TSN-KIT评估套件
  • 06年及以前韩国星际职业联赛及选手资料

应用程序编程接口大全_应用程序编程接口101相关推荐

  1. java编程代码大全_掌握Java编程技巧,代码重构

    代码重构在不改变软件系统外部行为的前提下,改善它的内部结构,通过调整程序代码改善软件的质量.性能,使其程序的设计模式和架构更趋合理,提高软件的扩展性和维护性. 代码重构目标 持续纠偏和改进软件设计 随 ...

  2. vb初学者编程代码大全_学习VB编程第14天,一个简单的排序代码把我难住了

    今天学习了刘金玉老师VB编程教程的第21期,学习的主要内容是冒泡排序算法. 一.算法的主要种类 1.算法的种类有冒泡排序法.选址排序法.折半查找法.快速排序法.穷举法等. 2.补充知识:variant ...

  3. python天勤金叉编程代码大全_这些Python编程黑科技,装逼指南,高逼格代码,让你惊叹不已...

    1.单行写一个评级组件 "★★★★★☆☆☆☆☆".slice(5 - rate, 10 - rate);定义一个变量rate是1到5的值,然后执行上面代码,看图 才发现插件什么的都 ...

  4. 小程序模板网站平台_小程序模板平台哪个好

    小程序模板网站平台_小程序模板平台哪个好?分享一个微信小程序模板平台,超60个行业的小程序模板免费使用,页面内容丰富样式多样的,小程序界面模板. 微信小程序模板网站平台 微信小程序模板平台的存在,就是 ...

  5. 读书笔记之:C/C++程序员实用大全—C/C++最佳编程指南

    这本书中列出了31章共1500个知识点,带有很多的例子.本书适合对C/C++有一些了解的程序员进行查缺补漏.因为这里边对知识点的讲解比较凌乱不是很条理,前面的内容有时就用到了后面内容,如果你不是了解的 ...

  6. 程序编程代码大全_CNC加工中心程序代码大全

    手工编程是指编程的各个阶段均由人工完成.利用一般的计算工具,通过各种三角函数计算方式,人工进行刀具轨迹的运算,并进行指令编制. 这种方式比较简单,很容易掌握,适应性较大. 下面我们了解一下数控编程步骤 ...

  7. python海龟画图代码大全_【程序源代码】python 海龟画图

    关键字: 正文 | 内容 今天这篇文章主要是介绍:python 海龟画图画一个正方形图案 01 - Turtle库是Python语言中一个很流行的绘制图像的函数库,想象一个小乌龟,在一个横轴为x.纵轴 ...

  8. python编程无师自通专业程序员的养成_正版 Python编程无师自通——专业程序员的养成 算机与互联网 编程语言与程序设计 计算机 网络...

    第一部分编程简介 第1章概述3 1.1本书的结构4 1.2从终点出发4 1.3你不是一个人在战斗5 1.4自学的优势5 1.5为什么应该编程5 1.6坚持不懈6 第一部分编程简介 第1章概述3 1.1 ...

  9. wordvba编程代码大全_这几本基础编程书籍一定要看

    程序员书库(ID:OpenSourceTop) 编译书单来自:https://simpleprogrammer.com/best-programming-books-2019/ 关于程序员类的技术书籍 ...

最新文章

  1. Redis最佳实践:7个维度+43条使用规范,带你彻底玩转Redis | 附实践清单
  2. User Profile Service 服务未能登录转载自(sailing的新浪博客)
  3. Lucene默认的打分算法——ES默认
  4. java参数传入泛型类型_Java 5.0 泛型之 使用泛型统一传入的参数类型
  5. 大数运算(2)——大数加法
  6. 普通Java对象怎么计算大小(字节长度)?
  7. jeecg选择按钮带入其他单据值
  8. 1451C. String Equality
  9. ConsumerCoordinator分析
  10. 你们觉得生一个孩子好,还是生两个孩子好?
  11. 用python读取txt文件、并计算数据的总合和平均值_Python,读取许多文件并合并结果...
  12. 三星note10显示无法连接服务器,三星Note10+ 体验后遇到的小麻烦
  13. 如何找到计算机上的画图拦,电脑中自带的Window画图工具不见了怎么恢复
  14. 「运维之美」技术周刊 ( 第 2 期 )
  15. 一文搞懂“如何通过群晖+DNSPod DDNS搭建私有云服务?”
  16. 数据库系统发展的特点
  17. MSComm控件的有趣现象
  18. MFC绘图工具High-speed Charting Control(VS2019)
  19. 微信商城后台服务器在那儿里,第3讲 微信商城云服务器后台创建
  20. 认识“Silverlight”

热门文章

  1. 最好用的 20 款数据可视化工具
  2. icc校色文件使用教程_浅谈如何用ICC文件进行校色,校色前后效果展示
  3. 帆软报表决策系统跨域登录
  4. ipad屏幕镜像_如何在Windows PC上镜像iPhone或iPad的屏幕
  5. x5550支持服务器内存吗,英特尔® 至强® 处理器 X5550
  6. 编译openssl1.1.1f for android
  7. css如何选择同一个class下的第一个div?
  8. 自己整理的英语一最终作文模板
  9. Nvidia Isaac Sim ROS机器人仿真和AMR开发环境
  10. 如何用SQL做留存率分析