云学编程的第19天—【微软官方python入门教程 P36笔记】2021-11-19 Calling an API

本文介绍了Web服务的概念及其工作原理。Web服务允许开发者分享功能而无需直接分享代码,通过将功能部署到Web服务器上实现。文章还解释了API的作用,即定义如何调用这些服务,并讨论了HTTP协议中GET和POST请求的区别。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

What is a web service?

When a developer wants to share the functionality of a function but not the actual code in the program, they can place the function on a web server. 

A programmer with the address of that function on the web server and the required permissions can call the function.

This is called a web service.

举例:

Computer Vision API - v2.0

What is an API

You can't call a function unless you know the function name and the required parameters.

When you create a web service you create an Application Programming Interface(API).

The API defines the function names and parameters so others know how to call your function.

Keys allow me to track which users have permission to use my web service.

A developer signs up on my web site, or buys a license for my software and is provided a unique key.

When the developer calls my web service they provide their unique key and I am able to verify the key has been approved for calls to my web service.

There is a standard for sending messages across the web

Hypertext Transfer Protocol(HTTP)is standard protocol for sending messages across the web.

`GET

1.pass values in query string only

2.special characters must be "escaped"

3.limited amount of data

`POST

1.pass values in query string and body

2.No need to escape speacial characters if passed in body

3.Can pass large amounts of data, including images, in body 

The requests library simplifies HTTP calls from Python code.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值