我应该如何构建良好的(网络)API [英] How should I build a good (web) API

查看:73
本文介绍了我应该如何构建良好的(网络)API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将为网络应用构建API,我对人们可以建议的良好做法感兴趣.

I'm going to build an API for a web app and I'm interested in what people can suggest as good practices.

我已经计划对其进行版本控制(版本1只能控制系统的某些方面,版本2可以控制更多功能,但这可能需要更改执行身份验证的方式,而该方式与版本1不兼容) ,并且身份验证将不同于人们用来登录的标准用户名/密码(如果有人确实使用了恶意工具,那么无论api允许什么,它都不会使其完全模仿).

I'm already planning to make it versioned (version 1 can only control certain aspects of the system, version 2 could control more, but this may need a change in the way authentication is performed that would be incompatible with version 1), and the authentication will be distinct from the standard username/password people use to log in (if someone does use a malicious tool it won't open them up to full impersonation, just whatever the api allows).

有人有进一步的想法吗,还是您使用的具有特别好的API的网站示例?

Does anyone have further ideas, or examples of sites with particularly good APIs you have used?

推荐答案

阅读 RESTful Web服务书,它为您提供了有关如何在实践中使用REST的很好的概述,并以足够的信心快速入门到现在开始的速度.这比仅查看现有API更为有用,因为它还讨论了设计选择和折衷方案.

Read the RESTful Web Services book, which give you a good overview of how to use REST in practice, and get to up to speed quickly enough to get started now, with some confidence. This is more useful than just looking at an existing API, because it also discusses design choices and trade-offs.

这篇关于我应该如何构建良好的(网络)API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆