GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Amazon Appstore Developer Docs
  • App Submission

This view

  • Original page
  • New address

GeezerVison is showing developer.amazon.com — Python Example | App Submission

Amazon Developer
Alexa
Amazon Appstore
Ring
AWS
Documentation

Console

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases

Console

as

Fire OS Developer Docs
Home
Develop
Test
Publish
Monetize
Engage users
Device specifications
Resources
App Submission

Collapse All | Expand All


  • << Amazon Appstore Developer Docs
    • App Submission Overview
      • Understanding Amazon Appstore Submission
      • Get Started with App Submission
      • Distribute Your App Internationally
      • App Submission Glossary
      • App Submission FAQ
      • FAQ Index
      • Release Notes
    • Manage Your Developer Account
      • Manage Your Amazon Developer Account and Permissions
      • Change Developer Account Ownership
      • Two-Step Verification FAQ
      • Track Account Activity with Activity Log
    • Account Identity Verification
      • Identity Verification
      • Accepted IDs
      • Taking Photos of Your ID
    • Prepare Your App
      • Amazon Appstore Presubmission Checklist
      • Appstore Privacy Labels
      • User Account and Data Deletion
      • User Age Verification
      • Integrate and Test the GetUserAgeData API
      • App Bundles
      • Device Filtering and Compatibility on Fire OS
      • Manifest Filters Supported by the Amazon Appstore
      • Troubleshooting Android Manifest and Device Filtering
      • Choosing a Category for Your App
      • Taking Screenshots on Fire Devices
    • Publish Your App
      • Submit Your App to the Amazon Appstore
      • Step 1: Upload Your App File
      • Step 2: Target Your App
      • Step 3: Add Appstore Details
      • Step 4: Review and Submit
    • Update Your App
      • Update a Published App
      • Release Your App Update in a Staged Rollout
      • Unlisting An App Version from the Amazon Appstore
      • Transfer Your App to Another Developer
    • Troubleshooting
      • Compile Errors from Referencing More Than 65,000 Methods
      • Troubleshooting SSL Validation
    • App Submission API
      • API Overview
      • Authentication
      • Task Flows
      • Differences from Play Store API
      • Python API Example
      • App Submission API Reference

    Python Example

    The following examples show Python code for various tasks using the App Submission API.

    Tip: For details about API requests and responses, see App Submission API Reference.
    • Obtain Access Token
    • Create a New Edit
    • Get the Open Edit
    • Replace an Existing APK
    • Add a new APK
    • Update a Listing

    Obtain Access Token

    Use your client ID and client secret to obtain an auth token. You will add the auth token to the header of each API request. The following Python example shows how to obtain an auth token and create the Authorization header using the token.

    #  Values that you need to provide
    client_id = "<your client id>"
    client_secret = "<your client secret>"
    app_id = "<your app id>"
    
    BASE_URL = 'https://developer.amazon.com/api/appstore'
    
    scope = "appstore::apps:readwrite"
    grant_type = "client_credentials"
    data = {
        "grant_type": grant_type,
        "client_id": client_id,
        "client_secret": client_secret,
        "scope": scope
    }
    amazon_auth_url = "https://api.amazon.com/auth/o2/token"
    auth_response = requests.post(amazon_auth_url, data=data)
    
    # Read token from auth response
    auth_response_json = auth_response.json()
    auth_token = auth_response_json["access_token"]
    
    auth_token_header_value = "Bearer %s" % auth_token
    
    auth_token_header = {"Authorization": auth_token_header_value}
    

    Create a New Edit

    The following Python example shows how to create an Edit.

    create_edit_path = '/v1/applications/%s/edits' % app_id
    create_edit_url = BASE_URL + create_edit_path
    create_edit_response = requests.post(create_edit_url, headers=headers)
    current_edit = create_edit_response.json()
    
    edit_id = current_edit['id']
    

    Get the Open Edit

    The following example shows how to get the Id of the open Edit.

    get_edits_path = '/v1/applications/%s/edits' % app_id
    get_edits_url = BASE_URL + get_edits_path
    get_edits_response = requests.get(get_edits_url, headers=headers)
    current_edit = get_edits_response.json()
    
    edit_id = current_edit['id']
    

    Replace an Existing APK

    The following example shows how to replace the first APK file with a file from your local machine.

    ## Get the current list of APKs
    get_apks_path = '/v1/applications/%s/edits/%s/apks' % (app_id, edit_id)
    get_apks_url = BASE_URL + get_apks_path
    apks = requests.get(get_apks_url, headers=headers)
    
    firstAPK = apks[0]
    apk_id = firstAPK['id']
    replace_apk_path = '/v1/applications/%s/edits/%s/apks/%s/replace' % (app_id, edit_id, apk_id)
    
    ## Open the apk file on your local machine
    local_apk = open(local_apk_path, 'rb').read()
    
    replace_apk_url = BASE_URL + replace_apk_path
    all_headers = {
        'Content-Type': 'application/vnd.android.package-archive',
        'If-Match': etag
    }
    all_headers.update(headers)
    replace_apk_response = requests.put(replace_apk_url, headers=all_headers, data=local_apk)
    
    

    Add a new APK

    The following example shows how to upload a new APK file.

    add_apk_path = '/v1/applications/%s/edits/%s/apks/upload' % (app_id, edit_id)
    add_apk_url = BASE_URL + add_apk_path
    local_apk = open(apk_location, 'rb').read()
    all_headers = {
        'Content-Type': 'application/vnd.android.package-archive'
    }
    all_headers.update(headers)
    add_apk_response = requests.post(add_apk_url, headers=all_headers, data=local_apk)
    response = add_apk_response.json()
    

    Update a Listing

    The following example shows how to update the store listing for a locale.

    listing_headers = headers.copy()
    listing_headers.update({
        'Content-Type': 'application/json'
    })
    listings_etag, current_listing_json = get_current_listing(app_id, edit_id, language, listing_headers)
    
    edit_body = current_listing_json.copy()
    edit_body.update(edit_listing_body)
    edit_listing_headers = listing_headers.copy()
    edit_listing_headers.update({
        'If-Match': listings_etag
    })
    
    edit_listing_response = update_listing(app_id, edit_id, language, edit_body, edit_listing_headers)
    

    Last updated: Jan 26, 2023


    • Obtain Access Token
    • Create a New Edit
    • Get the Open Edit
    • Replace an Existing APK
    • Add a new APK
    • Update a Listing
    Follow us:

    Resources

    • Appstore developer blog

    • Technical documentation

    • Amazon Developer Huddle

    Supported devices

    • Amazon Fire TV

    • Fire tablets

    Other services & APIs

    • Small Business Accelerator Program

    • Developer Promotions Console

    • Alexa for video publishers

    • Login with Amazon

    • Frustration-Free Setup

    • Amazon Incentives API

    • Amazon Merch on Demand

    • Amazon Music

    • Fire TV Partners

    Support

    • Appstore Developer Community

    • FAQs

    • Contact us

    Legal

    • Terms & agreements

    • Privacy Notice

    amazon_developer_logo

    © 2010-2026, Amazon.com, Inc. or its affiliates. All Rights Reserved.

    Terms

    Amazon Developer Blog

    Contact Us

    You are visitor 01402503 — GeezerVison does not store the pages you look up.
    Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.