Amazon Developer

as

Settings
Sign out
Notifications
Alexa
Amazon Appstore
Ring
AWS
Documentation
Support
Contact Us
My Cases
Devices
Build
Test
Publish
Connect
Documentation
Skip to main content
This page contains example code that shows how to access the GetUserAgeData API from your app and how to consume the responses. The example code provides a test implementation that you can use to simulate the actual API’s behavior. For developing and testing your integration of the GetUserAgeData API, you can use the provided non-production values in the AmazonUserDataClient class in combination with the TestContentProvider class, which serves mock data.

Overview

To integrate the GetUserAgeData API in your app, use the following high-level steps:
  1. If testing with mock data, register the TestContentProvider class in the Android manifest of the app that you’re using to test.
  2. Create a simple Java object to hold the user age data.
  3. Create a helper class that models the extracted user age data from the Java object.
  4. Implement the AmazonUserDataClient class to query for user age data.
  5. Call the AmazonUserDataClient class from your app where you’ll add logic to handle the response.

For testing

In the version of the AmazonUserDataClient class that you use for testing:
  • Set the AUTHORITY string to amzn_test_appstore
  • Set the PATH string to /getUserAgeData?testOption=k (where k is a number from 1 to 11)
These are non-production values and won’t access Amazon systems. The implementation of the TestContentProvider class provided on this page returns mock response combinations based on the actual response structure of the GetUserAgeData API. To test the functionality, pass a value from 1 to 11 in the testOption query parameter. The TestContentProvider class returns a response that corresponds to the value of the testOption parameter. For a list of the available mock responses provided, see Test data responses.

For production

For production, omit the TestContentProvider class and its manifest registration, and point your app to the production GetUserAgeData API. To use the production GetUserAgeData API, in the AmazonUserDataClient class:
  • Set the AUTHORITY string to amzn_appstore
  • Set the PATH string to /getUserAgeData
If you call the GetUserAgeData API before it returns live responses, you will get one of these values: null, Exception, or FEATURE_NOT_SUPPORTED.

AmazonUserDataClient

The following is example code that calls the mocked GetUserAgeData API from your app.
To handle the user data response, use the following “plain old Java object” (POJO) model. For more details, see GetUserAgeData API.

UserAgeDataResponse

In the AmazonUserDataClient class, you can use the following helper class that models the user age data that you extract. The example code in the AmazonUserDataClient section uses this helper class.

TestContentProvider

The following implementations are completely standalone and don’t interact with Amazon Appstore. Use this class only for early development, unit tests, or testing purposes. It is neither intended for full stack integration tests nor for production usage. With the implementation of the TestContentProvider class, you can simulate the behavior of the actual GetUserAgeData API. In either a new app, a test app, or as test logic in your actual app, use the TestContentProvider class to get the mocked response. For details on the GetUserAgeData API response, see GetUserAgeData API.

Test data responses

The following table lists the ten mock responses returned from the TestContentProvider API as written in the previous section. testOption is a query parameter used only in the mock user data query to serve the following predefined responses.
testOption valueUse caseResponse data
1Response for user who is 18+ years old and who’s age is verified.
2Response for any user where age verification and consent isn’t ascertainable.
3Response for a user between the ages of 0 to 12 (inclusive).
4Response for a user between the ages of 13 to 15 (inclusive).
5Response for a user between the ages of 16 to 17 (inclusive).
6Response for a user who is under 18 years old where consent is pending, or where consent isn’t granted.
7Response for any scenario where age verification law isn’t applicable.
8Response for when the API returns APP_NOT_OWNED status.
9Response for when the API returns INTERNAL_TRANSIENT_ERROR status.
10Response for when the API returns INTERNAL_ERROR status.
11Response for when the API returns FEATURE_NOT_SUPPORTED status.

Register the TestContentProvider class in your Android manifest

To use the TestContentProvider class, you must register it in your AndroidManifest.xml file. Only the app that is going to serve you the TestContentProvider API logic, such as a test app, requires this registration step. Change the android:name attribute in the provider element to match the fully qualified class name of your TestContentProvider class.

Access the user data provided by Amazon in your app

The following code shows how to get the user data provided through the AmazonUserDataClient class. Use this code in your app where you’ll add logic to handle user age verification status and user age ranges.

Other language representations

This is example code only—refer to the language or framework’s official documentation for complete syntax.

React Native

Flutter

Last modified on September 25, 2026