Google Play 开发者 API

概述

Google Play Console 提供一套基于 REST 的 Web 服务 API,可让您直接对您的应用程序执行发布、报告和其他应用程序管理功能。

并非所有开发者都需要使用这些开发者 API — 在大多数情况下,您可以继续使用 Google Play Console 直接管理您的应用程序。但是,如果您有大量 APK 要管理,或者必须跟踪用户购买和订阅,您可能会发现这些 API 有用。

包含的内容

Google Play 开发者 API 可让您专注于设计和开发应用程序,同时花费更少的时间和精力来管理您的发布,即使您扩展到新市场也是如此。

Google Play Console 包含一套 API,您可以使用它们来管理您的应用程序

  • The Publishing API lets you upload and publish apps, and perform other publishing-related tasks.
  • The Subscriptions and In-App Purchases API allows you to manage in-app purchases and subscriptions. (This was previously known as the "Purchase Status API".)
  • The Reporting API allows you to retrieve information about your app's quality from Android vitals.
  • The Reply to Reviews API allows you to retrieve and reply to reviews of your app.
  • The Permissions API allows you to automate permission management within the Play Console.
  • The Play Games Services Management API allows you to issue REST calls to programmatically control the metadata underlying the Google Play Games Services features.
  • The Voided Purchases API provides a list of orders that are associated with purchases that a user has voided.

入门

To get started with the Google Play Developer APIs, see the getting started documentation.

Publishing API

The Publishing API allows you to automate frequent tasks having to do with app distribution. This provides functions similar to those available to a developer through the Play Console, such as

  • Uploading new versions of an app
  • Releasing apps, by assigning APKs to various tracks (alpha, beta, staged rollout, or production)
  • Creating and modifying Google Play Store listings, including localized text and graphics and multidevice screenshots

Those tasks are performed using the edits functionality, which takes a transactional approach to making changes. This lets you bundle several changes into a single draft edit, then commit the changes all at once. (None of the changes take effect until the edit is committed.)

最佳实践

  • Limit the number of app updates. Don't publish alpha or beta updates more frequently than once a day (production apps should be updated even less frequently than that). Every update costs your users time and possibly money. If you update too frequently, users might start ignoring updates, or even uninstall the product.

Subscriptions and In-App Purchases API

The Subscriptions and In-App Purchases API allows you to manage your app's catalog of in-app products and subscriptions. In addition, with the Subscriptions and In-App Purchases API, you can quickly retrieve the details of any purchase using a standard GET request.

In the request, you supply information about the purchase — app package name, purchase or subscription ID, and the purchase token. The server responds with a JSON object describing the associated purchase details, order status, developer payload, and other information.

You can use this API in several ways, such as for reporting and reconciliation of individual orders and for verifying purchases and subscription expirations. You can also use the API to learn about canceled orders and confirm whether in-app products have been consumed, including whether they were consumed before being canceled.

最佳实践

  • Store subscription information on your server to avoid making unnecessary API calls. When your app needs to verify a subscription, you should rely on the cached information on your server instead of repeating the API call to Google.
  • There are two scenarios in which your secure server should use the Google Play Developer API to get subscription information
    • Your server receives a new purchase token that has not been seen before.
    • Your server receives a real-time developer notification (RTDN), which indicates that you need to use the purchase token to get the new subscription information.
  • Don't poll the API for subscription status on a regular basis. For example, don't call the API daily to check each subscription.
  • Since you receive an RTDN when the subscription expires or renews, you don't need to schedule an API call based on the scheduled expiry time.

Reporting API

The Reporting API is for developers who want to build automated workflows on top of Play Console data, or developers who use Play Console data for internal business reporting and analysis, potentially alongside other datasets. This gives you programmatic access to app-level data and metrics for internal reporting, analysis, and automation.

The reporting API offers access to Android vitals data, including crash rate, ANR rate, wake-up and wake-lock issues, and error stack traces.

最佳实践

  • This version of the Reporting API has a default limit of 10 queries per second. You can view your quota usage in the Quotas section of the Google Cloud Console. If you need to exceed this limit, you can submit a quota request using this form.

Reply to Reviews API

The Reply to Reviews API allows you to view user feedback for your app and reply to this feedback. You can use this API to interact with users directly within your existing customer support toolkit, such as a CRM system.

The Reply to Reviews API allows you to access feedback only for production versions of your app. If you want to see feedback on alpha or beta versions of your app, use the Google Play Console instead. Also, note that the API shows only the reviews that include comments. If a user rates your app but does not provide a comment, their feedback is not accessible from the API.

Permissions API

The Permissions API gives developers the ability to automate permission management within the Play Console. This can allow you flexible control over who has access to your developer account, without manual involvement.

With the Permissions API, you can perform administrative functions such as

  • Removing users' access when they leave your company.
  • Granting access to an app when a user joins the relevant team.

Voided purchases API

The Voided Purchases API provides a list of orders that are associated with purchases that a user has voided. You can use information from this list to implement a revocation system that prevents the user from accessing products from those orders.

This API applies to one-time in-app orders and app subscriptions.

A purchase can be voided in the following ways

  • The user requests a refund for their order.
  • The user cancels their order.
  • An order is charged back.
  • Developer cancels or refunds order. Note: only revoked orders will be shown in the Voided Purchases API. If developer refunds without setting the revoke option, orders will not show up in the API.
  • Google cancels or refunds order.

By using this API, you help create a more balanced and fair experience for all of your app's users, particularly if your app is a game.