gp-purchase-status-api.jd revision d28470e87a6521ff0fe7da843259657d9b1f661c
1page.title=Google Play Developer API
2page.tags="In-app Billing", "Google Play", "inapp billing", "in app billing", "iab", "billing", "publishing"
3
4@jd:body
5
6<div id="qv-wrapper">
7<div id="qv">
8  <h2>In this document</h2>
9  <!-- TODO: Update TOC -->
10  <ol>
11    <li><a href="#publishing_api_overview">Publishing API</a>
12    <li><a href="#subscriptions_api_overview">Subscriptions and In-App
13          Purchases API</a></li>
14    <li><a href="#using">Using the API</a>
15    <li><a href="#edits">Staged Edits</a></li>
16    <li><a href="#practices">Using the API Efficiently</a>
17      <ol>
18        <li><a href="#quota">Quota</a></li>
19      </ol>
20    </li>
21  </ol>
22
23  <h2>See also</h2>
24  <ol>
25    <li><a href="https://developers.google.com/android-publisher/">Google Play
26        Developer API</a> documentation</li>
27    <li><a href="https://support.google.com/googleplay/android-developer/answer/6071616">Google
28        Help Center</a> overview of the Google Play Developer API</li>
29  </ol>
30</div>
31</div>
32
33<p>The Google Play Developer API is a REST-based web service that allows you to perform publishing
34and app-management tasks. You can use this API to integrate your publishing
35operations with your release-management process.</p>
36
37<p>Not all developers will need to use these APIs&mdash;in most cases you will
38continue to manage your apps directly using the Google Play Developer Console.
39However, if you have a large number of APKs to manage, or have to track user
40purchases and subscriptions, you may find this API very useful.</p>
41
42<p>Using the Google Play Developer API, you can automate a variety of
43app-management tasks, including:</p>
44
45<ul>
46<li>Uploading and releasing new versions of your app</li>
47<li>Editing your app Google Play Store listings, including localized text and
48    graphics</li>
49<li>Managing your in-app product catalog, your products purchase status and your
50    app subscriptions</li>
51</li>
52</ul>
53
54
55
56<p>The Google Play Developer API lets you focus on designing and developing your
57app, while spending less time and effort managing your releases, even as you
58grow to new markets.</p>
59
60<p>The Google Play Developer API includes two components:</p>
61
62<ul>
63<li>The <a href="#publishing_api_overview">Publishing API</a> lets you upload and publish
64  apps, and perform other publishing-related tasks.</li>
65<li>The <a href="#subscriptions_api_overview">Subscriptions and In-App Purchases
66  API</a> lets you manage in-app purchases and subscriptions. (This was
67  previously known as the "Purchase Status API".)</li>
68</ul>
69
70<h2 id="publishing_api_overview">Publishing API</h2>
71
72<p>
73The Google Play Developer Publishing API allows you to automate frequent tasks
74having to do with app distribution. This provides functions
75similar to those available to a developer through the Google Play
76Developer Console, such
77as:
78</p>
79
80<ul><li>Uploading new versions of an app</li>
81<li>Releasing apps, by assigning APKs to various <em>Tracks</em> (alpha, beta,
82  staged rollout, or production)</li>
83<li>Creating and modifying Google Play Store listings, including localized text
84  and graphics and multi-device screenshots</li></ul>
85
86<p>Those tasks are performed using the
87<a href="#edits">edits</a>
88functionality, which takes a transactional approach to making changes &mdash;
89you bundle several changes into a single draft edit, then commit the changes all
90at once. (None of the changes take effect until the edit is committed.)</p>
91
92<p class="note"><strong>Note:</strong> Not all developers will need to use this
93API. All the functionality provided by the API is also available through the
94Google Play
95Developer Console. However, this API lets you integrate your app and listing
96update process with your existing tools, which will be very useful for some
97developers. In particular, if you have a large number of APKs to manage, or
98localized listings in many different locales, you may find this API invaluable.
99</p>
100
101<h2 id="subscriptions_api_overview">Subscriptions and In-App Purchases API</h2>
102
103<p>The API allows you to manage your app's catalog of in-app products and
104subscriptions. In addition, with the Subscriptions and In-App Purchases API you
105can quickly retrieve the
106details of any purchase using a standard GET request. In the request you supply
107information about the purchase &mdash; app package name, purchase or
108subscription ID, and the purchase token. The server responds with a JSON object
109describing the associated purchase details, order status, developer payload, and
110other information.</p>
111
112<p>You can use the Purchase Status API in several ways, such as for reporting
113and reconciliation of individual orders and for verifying purchases and
114subscription expirations. You can also use the API to learn about cancelled
115orders and confirm whether in-app products have been consumed, including
116whether they were consumed before being cancelled.</p>
117
118<p class="note"><strong>Note:</strong> The Subscriptions and In-App
119Purchases API does not use the new, transactional "edits" functionality used by
120the <a href="#publishing_api_overview">Publishing API</a>. Methods for the
121<a href="https://developers.google.com/android-publisher/api-ref/inappproducts">Inappproducts</a>,
122<a href="https://developers.google.com/android-publisher/api-ref/purchases/products">Purchases.products</a>,
123and <a href="https://developers.google.com/android-publisher/api-ref/purchases/subscriptions">Purchases.subscriptions</a>
124resources take effect immediately. Each resource's API reference page notes
125specifically whether the methods for that resource use the "edits"
126model.</p>
127
128<p>The Purchase Status API is part of the <a
129href="https://developers.google.com/android-publisher/">Google Play Developer
130API</a> v. 2.0, available through the Google Developers Console.</p>
131
132<h2 id="using">Using the API</h2>
133
134<p>To start making API calls, you’ll set up and manage the Google Play Developer
135API directly from the <a href="https://play.google.com/apps/publish/">Google
136Play Developer Console</a>. The API can only be managed by the owner of your
137Google Play Developer account.</p>
138
139<p>To access the API, you'll need to:</p>
140
141<ol><li>Set up a new or existing API project</li>
142<li>Set up one or more authorized clients, which can be either:
143<ul>
144  <li><a href="https://developers.google.com/accounts/docs/OAuth2">OAuth
145      clients</a></li>
146  <li><a href="https://developers.google.com/accounts/docs/OAuth2ServiceAccount">
147      service account</a></li>
148</ul></li></ol>
149
150<p>For full details, see the Google Play Developer API
151<a href="https://developers.google.com/android-publisher/getting_started">Getting
152Started</a> page.</p>
153
154<h2 id="edits">Staged Edits</h2>
155
156<p>The Google Play Developer Publishing API Edits methods allow you to prepare
157and commit changes to your Google Play apps. Once your update is ready to go,
158you can deploy it with a single operation. The changes you can make include:</p>
159
160<ul>
161  <li>Uploading one or more APKs</li>
162  <li>Assigning different APKs to different “tracks”: alpha, beta, staged
163      rollout, and production</li>
164  <li>Creating and modifying localized store listings for the app</li>
165  <li>Uploading screenshots and other images for the app’s store listings</li>
166</ul>
167
168<p>Once all the desired changes have been staged, they are all committed with a
169single operation.</p>
170
171<p>For full details on staged edits, see the Google Play Developer API
172<a href="https://developers.google.com/android-publisher/edits/">Edits</a>
173page.</p>
174
175<p class="note"><strong>Note:</strong> The new, transactional "edits"
176functionality is only used by the <a href="#publishing_api_overview">Publishing
177API</a>. Methods for the <a href="#subscriptions_api_overview">Subscriptions and
178In-App Purchases API</a> take effect immediately. Each resource's API reference
179page notes specifically whether the methods for that resource use the "edits"
180model.</p>
181
182<h2 id="practices">Using the API Efficiently</h2>
183
184<p>Access to the Google Play Developer API is regulated to help ensure a
185high-performance environment for all applications that use it (as described in
186<a href="#quota">Quota</a>). While you can
187request a higher daily quota for your application, we highly recommend that you
188minimize your access using these techniques: </p>
189
190<ul>
191  <li><em>Limit the number of app updates</em> &mdash; Do not publish alpha or beta
192  updates more frequently than once a day. (Production apps should be updated
193  even less frequently than that.) Every update costs your users time and
194  possibly money. If you update too frequently, users will start ignoring
195  updates, or even uninstall the product. (Of course, if there's a major problem
196  with your app, go ahead and fix it.)</li>
197  <li><em>Query the Purchase Status API for new purchases only</em> &mdash; At
198  purchase, your app can pass the purchase token and other details to your backend
199  servers, which can use the Purchase Status API to verify the purchase.</li>
200  <li><em>Cache purchase details on your servers</em> &mdash; To the extent possible,
201  cache the purchase details for in-app products and subscriptions on your backend
202  servers. If your app contacts your backend servers at runtime to verify purchase
203  validity, your server can verify the purchase based on the cached details, to
204  minimize use of the Purchase Status API and to provide the fastest possible response
205  (and best experience) for the user.</li>
206  <li><em>Store subscription expiry on your servers</em> &mdash; Your servers should
207  use the Purchase Status API to query the expiration date for new subscription tokens,
208  then store the expiration date locally. This allows you to check the status of
209  subscriptions only at or after the expiration (see below).</li>
210  <li><em>Query for subscription status only at expiration</em> &mdash; Once your
211  server has retrieved the expiration date of subscription tokens, it should not query
212  the Google Play servers for the subscription status again until the subscription is
213  reaching or has passed the expiration date. Typically, your servers would run a batch
214  query each day to check the status of expiring subscriptions, then update the database.
215  Note that:
216    <ul>
217      <li>Your servers should not query all subscriptions every day.</li>
218      <li>Your servers should never query subscription status dynamically, based on
219      individual requests from your Android application.</li>
220    </ul>
221  </li>
222</ul>
223
224<p>By following those general guidelines, your implementation will offer the
225best possible performance for users.</p>
226
227<h3 id="quota">Quota</h3>
228
229<p>Applications using the Google Play Developer API are limited to an
230initial courtesy usage quota of <strong>200,000 requests per day</strong> (per
231application). This should provide enough access for publishing activities and
232normal subscription-validation needs.</p>
233
234<p>If you need to request a higher limit for your application, use the "Request
235more" link on the <strong>Quotas</strong>
236pane of the Google Developers Console.</p>
237