请求少于 50 个的 Google Places API OVER_QUERY_LIMIT



我刚刚开始使用谷歌地图和谷歌地方API来开发我正在开发的应用程序。向https://maps.googleapis.com/maps/api/place/autocomplete/json端点发送请求时,我不断收到OVER_QUERY_LIMIT错误,即使我发出的请求数量少得离谱。

我知道这不是 API 密钥,因为除非我更改或删除要发送的key查询参数,否则我不会收到无效密钥错误。

我调用API的代码(来自Android上运行的NativeScript Angular应用程序(:

import { Location as Geolocation } from "nativescript-geolocation";
import { TokenModel } from "nativescript-ui-autocomplete";
// And other stuff
// Injectable class, blah blah blah
public getRestaurantSuggestions(
search: string,
location: Geolocation = null
): Observable<TokenModel[]> {
let route: string = "https://maps.googleapis.com/maps/api/place/autocomplete/json";
route += `?key=${AppConstants.GOOGLE_MAPS_API_DEV_KEY}`;
route += `&keyword=${search}`;
route += "&types=establishment";
if (location) {
route += `&location=${location.latitude},${location.longitude}`;
route += `&radius=${AppConstants.GOOGLE_MAPS_SEARCH_RADIUS}`;
}
return this._http.get(route).pipe(
map((response: Response) => {
return response.json();
}),
map((response: {
error_message: string,
predictions: { name: string }[],
status: string
}) => {
if (response.error_message) {
throw new Error(`${response.status}: ${response.error_message}`);
}
return response.predictions.map(p => {
return new TokenModel(p.name, null);
});
}),
catchError((error: Error) => {
return throwError(error.message);
})
);
}

有趣的笔记:

  • 昨晚我提出了一些错误的请求,试图弄清楚如何使用 API
  • 尽管在我的 Google 开发人员控制台上看到不到 40 个请求,但我突然只得到OVER_QUERY_LIMIT错误响应
  • 今天(不到 24 小时后(我能够发送一个成功的请求,但随后又OVER_QUERY_LIMIT

以下是我在 Google 开发者控制台的"正在使用的 API"表中的当前数字:

In use APIs
Select an API to view details. Figures are for the last 30 days.
API                    |  Requests  |  Errors  |  ...
Maps SDK for Android   |  11        |  0       |  ...
Places API for Web     |  31        |  29      |  ...

如您所见,远远少于在不设置信用卡或其他任何内容的情况下应该允许的最大请求数。

发生了什么事情?

编辑

据此,谷歌刚刚对其进行了更改,因此您必须设置计费才能使用Places API。当我在开发应用程序的 alpha 版时刚刚熟悉 API 时,我非常不情愿这样做,但我会继续设置计费信息,看看是否可以修复它。

正如我所怀疑的那样。正如我在编辑我的问题时所说,根据这一点,谷歌只是对其进行了更改,以便您必须设置计费才能使用地点 API。

这种情况让我无休止地烦恼,但我想这就是你的谷歌。

现在我正在进行一次不同的冒险 - 每个请求都出现INVALID_REQUEST错误。

最新更新