TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Ask HN: How should I build my API?

8 点作者 relm86将近 15 年前
I want to build an API for my website but am unsure if I should make it a REST or SOAP based API and what kinds of features to implement in it any suggestions would be great.

6 条评论

pierrefar将近 15 年前
Please don't do SOAP. Please. It's painful to use as a developer. REST and REST-like services are much easier to build for, not to mention debug and test.<p>Think about the output your API will produce. JSON and/or an XML flavor? What about JSONP support?<p>And do you want users to identify themselves? How? An API key is the usual way, but Digg has a neat alternative (which I'm using for inspiration on a soon-to-launch API) of each API call providing an app identifier in the form of a URL of a web page describing the app.<p>Also, don't forget to version your API so that in the future if you implement a change that breaks the default or usual behavior, you can have a chance of maintaining backwards compatibility.<p>Rate limiting? If you want that, use memcached or Redis or any super-fast in-memory store.<p>Finally, log everything on the server.
apsurd将近 15 年前
REST and JSON hands down. So easy even <i>I</i> can do it. =) XML has been around but JSON is so much easier and more efficient that I tend to raise an eyebrow at services insisting I use XML =/<p>Start with basic GET services. Have users do admin stuff on your website. Then create embeddable widgets that present how to use your API to GET and display data from your service. Use javascript to fetch the JSON, and add it nicely to the DOM.<p>It's pretty fun actually.
评论 #1420383 未加载
joshu将近 15 年前
Consider your audience. Specifically: The simpler the API, the larger the set of people that will build on it.<p>Delicious used simple GETs with a few parameters and you could talk to it with a shell script.<p>Unfortunately, that was before the days of OAuth, which you really need to support these days. If people build apps that interface to your app, you don't want people typing their passwords in to the other app.
tworats将近 15 年前
Take a deep look at both Flickr and Twitter's APIs. Follow their model as much as you can.<p>Use JSON and as consistent an interface as you can come up with.<p>Think through how you'd rebuild your website using only your APIs.<p><a href="http://apiwiki.twitter.com/" rel="nofollow">http://apiwiki.twitter.com/</a><p><a href="http://www.flickr.com/services/api/" rel="nofollow">http://www.flickr.com/services/api/</a>
metachris将近 15 年前
This presentation from Jushua Bloch about "How to Design a Good API &#38; Why it Matters" is very interesting, informative and and inspiring:<p><a href="http://www.infoq.com/presentations/effective-api-design" rel="nofollow">http://www.infoq.com/presentations/effective-api-design</a>
gspyrou将近 15 年前
If you are using ASP.NET you may check the Web Application Toolkit: REST Services <a href="http://channel9.msdn.com/posts/LostInTangent/Web-Application-Toolkit-REST-Services/" rel="nofollow">http://channel9.msdn.com/posts/LostInTangent/Web-Application...</a>