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

科技回声

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

GitHubTwitter

首页

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

资源链接

HackerNews API原版 HackerNewsNext.js

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

Ask HN: How to protect public APIs from bots when using a BaaS?

14 点作者 raulk将近 8 年前
Say you have an listings&#x2F;classifieds app with public entries served via an API. How do you prevent bots from scraping and stealing your data by directly hitting your API?<p>If you build your own backend, you could put a gateway like Kong or similar in front —to detect and throttle&#x2F;ban robotic usage patterns.<p>But how do you achieve this if you use Firebase, Graphcool, or another Backend As A Service (BaaS)?<p>You could deploy a proxy&#x2F;gateway, but that would incur in an extra hop (= latency) for every single call.<p>EDIT: Actually, this question is applicable to any API, not just public ones. For private APIs restricted by login, the bot would simply have to create a user first.

2 条评论

tyingq将近 8 年前
I don&#x27;t know that there&#x27;s a generally applicable answer if the api calls are direct from end user -&gt; public api, and on infrastructure you don&#x27;t control.<p>The answers would be highly dependent on the specific service, and whatever capabilities they offer. Firebase, for example, has a concept of custom tokens where you could implement rules on a per-api-consumer basis.<p>There does seem to be an opportunity for CDN companies to offer an API gateway with throttle, scripting, oath, conditional caching, bot blocking, etc. I don&#x27;t know why they haven&#x27;t offered yet. A CDN hosted Tyk or Kong instance would likely be popular.
评论 #14384516 未加载
1ba9115454将近 8 年前
You could try an API key policy. Any calls to the API without a key would be throttled down to normal usage levels.<p>People can apply for an API key and you can monitor for any abuse.