Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Play Developer API: What is Edit Identifier for an APK and (how) can I find it programatically

I am trying to use GP Developer API (without much success) and keep returning to the issue of editID. For example on the reference page for Edits.apks:list, we see an example of HTTP request:

GET https://www.googleapis.com/androidpublisher/v3/applications/packageName/edits/editId/apks

What is editId there? Where do I find it for an APK that is already uploaded to GP Console? Even better, can I find it using the API itself?

like image 766
celaeno Avatar asked Dec 23 '22 17:12

celaeno


1 Answers

In case somebody is as baffled with the GP documentation as a I was:

GP Developer API docs for Edits (and congratulations if you figured out that you should be on the page called "Edits" if you are merely trying to obtain some info) mumbles something about "calling Edits: Insert and specifying the app you want to modify." I am not trying to insert anything or modify anything in any way, but ok. Then "You can make the changes [...] by calling the appropriate method passing the IDs of the app and edit you want to modify." Which edit ID?

Long story short, it looks like GP wants you to request a stamp for each exchange session you are going to have with their server, and then label all interactions with that stamp. The way you get the stamp is by calling the insert function with your apk name and no further arguments (duh).

So in python it should look something like this:

from googleapiclient import discovery
from google.oauth2 import service_account

package_name = "com.pkg.name"

scopes = ['https://www.googleapis.com/auth/androidpublisher']
sa_file = "your_key.json"

credentials = service_account.Credentials.from_service_account_file(sa_file, scopes=scopes)

# see the list of discoverable api's here https://www.googleapis.com/discovery/v1/apis
service = discovery.build('androidpublisher', 'v3', credentials=credentials)

# note that insert() returns a request that needs to be exexuted
request = service.edits().insert(packageName=package_name)
response = request.execute()
editId = response['id']

# say you want to know the details about your package
request = service.edits().details().get(packageName=package_name, editId=editId)
response = request.execute()
print(response)

There.

like image 139
celaeno Avatar answered May 16 '23 07:05

celaeno