SDK和API区别

news2025/2/21 6:22:23

B站视频:https://www.bilibili.com/video/BV1dA411K7Ps/?spm_id_from=333.337.search-card.all.click&vd_source=85701dd8aeeae2aaac0299ea796f19bb

 

假设你在开发一款移动端兽医诊所应用

Let's say you're developing a mobile app for a veterinarian clinic

想法是该移动端应用

and the idea is for this mobile app to actually  

当宠物走入诊所允许接待员为其拍照

allow a receptionistto take a picture of a pet as it enters the clinic

应用会自动与视觉服务进行通信,都运行在云端

and the app will communicate with a visual recognition service, that's running on the cloud

服务器端想法就是,返回宠物名字,传回它们的文档

And the idea is for the service to return the pet's name and bring up their file

如何在移动和云服务端 之间通信呢?

How do we communicate between the mobile app and this cloud-based service

这就要用到API和SDK了

Well, that's where APIs and SDKs come in

从API开始谈起

Let's get started by talking about APIs

一、什么是API?What's an API

1、API概念

首先,API全部与通信有关

First of all, APIs are all about communication

应用或服务端有一组定义和协议,用于和其他应用或服务对话

There are a set of definitions and protocols for apps or services to talk to other apps or services

你可以将其视为一种桥梁,在应用和云视觉识别服务间

So you can kind of think of them like a bridge between your app and say this cloud-based visual recognition service

那么API到底代表什么,应用程序接口的缩写

So what does 'API' standfor anyway. Well, it's Application Programming Interface

哪些方面又使API有用呢?

And what are some of the aspects of APIs that make them useful

1)它们都是关于通信的

They're all about communication

服务器和其他服务器间,应用和其他应用间,彼此交流的方式

So communicating between a service and an other service, an app and another app, it's how they talk to each other

2)其次,它们都是关于抽象的

Next, they're all about abstraction

抽象是什么意思

What does 'abstraction' mean

在VR服务中,在云中,可能运行着成千上万行代码

So, inside the VR service up in the cloud, there's probably potentially thousands of lines of code running up there 

作为移动端开发的你,你不用去考虑,我调用服务中的哪个方法可以得到宠物名字

And you as a developer of a 010mobile app, you don't want to have to worry about which method in this service do I call to get the pet's name

API的作用就是,它可以抽象出所有复杂逻辑,只需要考虑自己需要的即可,简化了过程

So,what an API does is it abstracts away all that complicated logic,so you just have to worry about getting just the data you need.It simplifies the process.

3)API是标准化 (REST)

Third, APIs are standardized

有行业标准来说明如何定义API

Meaning, there's industry-defined standards for how to define an API

有很多流行的API格式

and there's a few formats that are popular for APIs

你可能听过SOAP,GraphQL, REST, REST表示表现层状态转换

You may have heard of SOAP GraphQL or REST,which fun fact stands for Representational State Transfer

正是本视频所关注的

and that's waht we'll focus on for this video

2、API的构成要素是什么

So,what are some of the building blocks of APIs

1)发送请求 make up a request

首先,要发送数据

First of all, to actually send data or send what's called a request

从移动端应用到云端的VR服务

from the mobile app to the VR service on the cloud

你需要做些不同事情

you need to have a few different pieces

① 操作 Operation

对于REST API调用请求,你需要有个所谓的“操作”

So, for a REST API call request, you need to have what's called an operation

可能是HTTP方法,像post,put,get,delete

So this could be HTTP methods,like POST, PUT, GET, DELETE

本例就是post方法

In this case it would be a POST method

向服务器发送一个请求

because you're sending a request over to the service

可能是文件名字,包含拍摄的宠物图像

which might include something like maybe the file name of the image you took of the pet

② 参数 Parametes

接下来是参数,这是可选的

Next, would be parameters,this is optional

本例就有可能是图像的文件夹名,也许是cat,jpeg,拍的一张喵片

In this case might be the file name of the image you took. So maybe cat.jpeg,if it's a cat that you took a picture of 

③ 结点 End point

最后就是结点,就是图像识别服务的UR,你尝试交互的

Finally, would be the end point.So, that's the URL basically of the visual recognition service that you're trying to talk to

可能是url / analyze

So, maybe that's, you know, it's some URL-slash-analyze

这就是你的请求对吧

Great, so that's your request, right

2)响应 Response

收到REST API返回的响应,从视觉识别服务返回的长什么样子呢?

What might a REST API response call that you receive back from the visual recognition service look like

基本上就是某种原始数据,也许是JSON

Typically it's some form of raw data,maybe JSON

响应就像这样,这种排序的数据对象,包含结果、类型就是cat、也许名字叫Mittens

So, a response might look something like this. So, you have sort of this data object, that might include the result,the type which is a cat, and maybe the name which in this case may be Mittens

这就是API的基本组成部分

Great, so that's sort of the building blocks of what an API is 

作为开发人员,如何在代码中调用API呢

As a developer though, how do you actually call an API in your code

你不想去担心设置请求的这些操作,参数,结点,以及处理原始JSON对象

You don't want to have to worry about setting up your request with all thest building blocks of operations,parameters,end points,and dealing with raw JSON objects

这就是SDK登场的地方

So that's where SDKs come in and really shine

二、什么是SDK?What's an SDK

让我们谈谈SDK,它表示什么

So, let's talk about SDKs, what does that stand for

软件开发工具包的缩写,很直接对吧

Well, it is Software Development Kit. Pretty straight forward,right?

可以把SDK想成工具箱,其中的工具(代码)会为你去调用API

So, SDKs, you can really think of like a toolbox of tools, or code that actually call APIs for you

你可能精通一门编程语言

So you may be specialized in one programming language over the other

在很多语言中都有SDK,也许是JAVA中的SDK,或者Node.js,也许GO,又或者Python

you know, there's SDKs in a variety of languages.So, there's maybe an SDKin Java, in Node,maybe GO, or Python

无论你擅长哪门语言,都有适合你的SDK

whichever language that is your specialty, there's probably an SDK for you

回到我们这里的例子,此例子中SDK长什么样

So, back to our example over here. what might an SDK look like in this example

要用SDK,将SDK工具箱放到移动端这里

So, with an SDK, let's go ahead and put our little SDK toolbox within the mobile app

本例由于是移动端,标注使用Java SDK

and for this case since it's a mobile app, say we'll use the Java SDK

在这个Java SDK中,不用通过手动构建模块配置这些请求

So, in this Java SDK, rather than having to configure your request manually with all these building blocks

你可能实际就调用一个方法,也许叫获得结果

you might actually call just a method,that's maybe called Idont know Get Result

就会调用不同的构建块:操作、参数、请求

that will actually call these various building blocks: the operation, the parameters, and the request for you

通过代码为你提供API请求

it'll make it for you and it'll make that API request for you with code

你会得到响应,也不一定是JSON对象,可能是一些代码,也许是Java本地对象模型,叫做分析响应对象

In response, you'll get a response,but it won't be necessarily a JSON object, it might be some code, maybe a native model object in Java, called an Analyze Respnse Object

代码就像这样,你有ARO

So, the code might look something like this. So, you have an Analyze Response Object

你调用图像识别分析和返回结果方法

that you call the 'Visual Recognition Analyze and Get Results' method

你传入cat.jpeg参数,就是文件的名字

You pass in a parameter which is 'cat.jpeg',which is the name of the file

发送给图像识别服务

that you sent over the visual recognition service

在响应中,可以在移动端设置一个标签,即Mittens

and in response, you can actually go ahead and set a label in your mobile app, to be Mittens

这就是Java中的ARO接收到的数据,通过你的SDK,就会看到Mittens走进了诊室

So, that's the data you received in the form of an analyze response model object in Java via your SDK and you're able to see Mittens has entered the building

希望以上总结,API是什么,SDK是什么,都有何用途

So,hopefully, this kind od summarizes, what's an API, what's an SDK, what are both used for

以及它们如何成为你云应用开发工具箱中,最基础的工具

and how they are truly fundamental tools in your cloud app development toolbox

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1098256.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

vue3怎么创建项目

1、先安装node.js 自行去node.js官网下载 2、创建一个文件夹 终端打开命令 3、执行命令 vue create 项目名称(必须是英文开头,可以英文数字) 4、选择Manually select features(自定义配置) 5、选择Router(后面要使用,也可以先不安装&am…

Sanic​——Python函数变成API的神器

今天给大家介绍一个超好用的框架,迅速将Python函数变成API,它就是最近越来越火的异步Web框架Sanic。 1. Sanic简介 Sanic 是 Python3.7 Web 服务器和 Web 框架,旨在提高性能。它允许使用 Python3.5 中添加的async/await语法,这使…

GPT4应用讲解,如何获取ChatGPT账号

参加每人均可获得1个独立可永久使用的ChatGPT账号,并提供不用fanqiang使用的方法。 前言 GPT对于每个科研人员已经成为不可或缺的辅助工具,不同的研究领域和项目具有不同的需求。例如在科研编程、绘图领域: 1、编程建议和示例代码: 无论你…

GFS分布式文件系统实验

GFS概念 Gluster 是一个开源的分布式文件系统 它是一个C/S架构 由存储服务器、客户端以及NFS/Samba存储网关组成 没有元数据服务器组件,这有助于提升整个系统的性能,可靠性和稳定性 文件系统定义 负责实现数据存储方式,以什么格式保存在…

idea 2022 一个工作空间下导入git项目 后 无法导入第二个git项目

idea 2022 一个工作空间下导入git项目 后 无法导入第二个git项目 如图所示 我导入了一个git项目后,菜单栏出现了一个git按钮 找不到 导入git项目的按钮了 方式1、 通过idea设置 打开全局设置 如下图 把git先改为none,保存 保存后就可以看到 VCS按钮 导入…

程序员架构修炼:架构设计概要,业务、应用、技术、数据架构

作为一个程序员,了解架构设计是非常重要的,它能够帮助你更好地理解如何构建大型软件系统,并能够满足用户的需求。在架构设计中,通常会涉及到四种不同类型的架构:业务架构、应用架构、技术架构和数据架构。 1、业务架构…

鸿蒙初体验

下载与安装DevEco Studio 在HarmonyOS应用开发学习之前,需要进行一些准备工作,首先需要完成开发工具DevEco Studio的下载与安装以及环境配置。 进入DevEco Studio下载官网,单击“立即下载”进入下载页面。 DevEco Studio提供了Windows版本和…

迅雷下载宝-openwrt-kodexplorer

下载仓库 雾渺/KODExplorer - Gitee.com 下载后解压上传文件/mnt/mmcblk0/kodexplorer ip:8080访问

NFTScan | 10.09~10.15 NFT 市场热点汇总

欢迎来到由 NFT 基础设施 NFTScan 出品的 NFT 生态热点事件每周汇总。 周期:2023.10.09~ 2023.10.15 NFT 热点资讯 01/ DeLabs:所有 DeGods 已重置回 Season1,用户可于本周将 y00ts 免费迁移至以太坊 10 月 9 日,DeGods & y…

分布式存储系统在智慧广电8K场景的融合应用

一、前言 广电行业的业务系统主要包含收录、编辑、播出、媒资管理、归档等环节,即通常所说的采、编、播、管、存业务,每个环节几乎都伴随着频繁的数据调取和使用。尤其在8K高清时代,视频码流已经从高清的100Mbps前进到400-2000 Mbps&#xf…

2022最新版-李宏毅机器学习深度学习课程-P14 批次(batch)与动量(momentum)

一、batch 回顾epoch、shuffle batch size大还是小?都有好处 大batchsize的好处 由于GPU有并行计算的能力,左边并不一定用时更长 反而是,batch size小的时候,要跑完一个epoch所用的update时间更长,所以时间方面的比较…

反序列化 apache mq 反序列化

1.解释一下apache mq Apache activemq 开放源代码消息中间件 java代码 操作系统只要有java虚拟机就可以执行 利用方法 2.文件配置不当 3.看版本 4.exp下载 5.exp使用 6.利用条件 7.反弹shell 加密解密 8.执行并且发送 9.利用成功 10.反弹shell成功 参照 【vul…

如何利用Web应用防火墙应对未知威胁

网络安全是一个永恒的话题,尤其是在未知威胁不断涌现的情况下。Web应用防火墙(WAF)是企业网络安全防线的重要组成部分,能够帮助企业在面对未知威胁时采取有效的防护措施。本文将探讨如何利用Web应用防火墙应对未知的网络威胁。 一…

京东商品详情API接口(item_get-获得京东商品详情接口),京东API接口系列

京东商品详情API接口(item_get-获得京东商品详情接口),京东API接口可获取到商品链接,商品ID,商品标题,商品价格,品牌名称,店铺昵称,sku规格,sku属性&#xff…

私域社群团购直播活动报名小程序开发

新零售SaaS系统,一款超级好用的私域社交团购小程序。支持团购、直播,有统计、收款、发货等功能。直播配合开团转化率更高,一款真正的私域卖货神器。 社交化电商用户踊跃参与:在卖货的同时,体现众多消费者的参与动态更…

nginx之正向代理、反向代理和负载均衡(重点)

一、nginx的两种代理方式 1、七层代理(http协议) 2、四层代理(tcp/udp流量转发) 二、四层代理和七层代理 (一)四层代理:基于tcp/udp协议的ip和端口转发数据包 1、四层代理无法获取http请求…

[Linux 基础] Linux编辑器Vim,你值得拥有

文章目录 1、Linux 软件包管理器 yum1.1 什么是软件包1.2 如何安装软件1.3 如何卸载软件 2、vim的使用2.1 vim的安装和配置2.2 vim的基本概念2.3 vim的基本操作 3、vim正常模式命令集4、vim注释与去注释5、Liunx编辑器-gcc/g使用5.1 如何使用gcc编译c程序5.2 gcc的翻译过程5.2.…

excel管理接口测试用例

闲话休扯,上需求:自动读取、执行excel里面的接口测试用例,测试完成后,返回错误结果并发送邮件通知。 分析: 1、设计excel表格 2、读取excel表格 3、拼接url,发送请求 4、汇总错误结果、发送邮件 开始实现…

字节跳动2023测试开发岗 3+1 面经+经验分享(收到offer,入职月薪27K)

现在,招聘黄金时间已经来临,在网上看了很多大佬的面经,也加了很多交流群,受到了很多朋友的提点,今天终于轮到我来分享面经啦,之前面试了几家公司,最后在十月初拿到了字节跳动测试岗的 offer&…

竞赛选题 深度学习YOLO图像视频足球和人体检测 - python opencv

文章目录 0 前言1 课题背景2 实现效果3 卷积神经网络4 Yolov5算法5 数据集6 最后 0 前言 🔥 优质竞赛项目系列,今天要分享的是 🚩 深度学习YOLO图像视频足球和人体检测 该项目较为新颖,适合作为竞赛课题方向,学长非…