Using the Chrome Web Store Publish API
Overview
The Chrome Web Store Publish API provides a set of REST endpoints for programmatically creating, updating, and publishing items in the Chrome Web Store.
Initial setup
Before you can begin making REST calls against the Chrome Web Store, you will need to enable the Chrome Web Store API, configure your OAuth consent screen, and retrieve your API access keys. The following sections walk through this process.
Enable the Chrome Web Store API
- Go to the Google Cloud Console.
- Create a new project or select an existing one.
- In the search bar type “Chrome Web Store API”.
- Enable the Chrome Web Store API.
Configure the OAuth consent screen
- Go to OAuth consent screen.
- Select External then Create.
- Fill out the required App information fields (listed below) then click Save and Continue.
- App name.
- User Support email.
- Developer contact email.
- Skip Scopes. click Save then Continue.
- Add your email address to Test users, then click Save then Continue.
Get the access keys
- Go to Credentials.
- Click Create Credentials then OAuth client ID.
- For Application type, choose Desktop App.
- Fill out the name, then click Create.
The console will provide the client ID and client secret.
Testing your OAuth application
You can retrieve an access token to work with the API. For example, enter this URL in your browser, replacing the $CLIENT_ID with the one for your app:
https://accounts.google.com/o/oauth2/auth?response_type=code&scope=https://www.googleapis.com/auth/chromewebstore&client_id=$CLIENT_ID&redirect_uri=urn:ietf:wg:oauth:2.0:oob
You will see a page asking you to accept permission for the requested scope.
Make sure you are requesting the token using the Google developer Account which owns the Chrome Web Store items you want to manage. This account can be different from the account you created the Google Developers Console project with. For example, you can create an application for other developers to manage their apps, in which case you only need to register a Google Developers Console project.
Click Accept and copy the code. It should look something like this:
Use this value to request an access token. For example, using curl
, you can get an access token by executing the following command (replacing the values of $CLIENT_ID, $CLIENT_SECRET, and $CODE with the values from above):
> curl "https://accounts.google.com/o/oauth2/token" -d \
"client_id=$CLIENT_ID&client_secret=$CLIENT_SECRET&code=$CODE&grant_type=authorization_code&redirect_uri=urn:ietf:wg:oauth:2.0:oob"
This will return a result such as:
{
"access_token" : "ya29...",
"expires_in" : 3600,
"refresh_token" : "1/rwn...",
"scope": "https://www.googleapis.com/auth/chromewebstore",
"token_type" : "Bearer",
}
You can now use the access_token
to call the API. You can also use the refresh token to get future access tokens. Note that tokens expire after an hour.
For more information about getting OAuth 2.0 access tokens, see Using OAuth 2.0 to Access Google APIs.
Using the API
Once you have an access token, your extension can then use the Chrome Web Store Publish API. There are endpoints for creating a new item, updating an existing item, and publishing an item.
Below is a list of considerations for using the Publish API:
- Developers are required to enable 2-Step Verification for their Google account to publish or update an existing extension.
- Before you can publish a new item, you have to fill out the Store Listing and Privacy practices tabs in the Developer Dashboard.
- After publishing a new or existing item, it will undergo a review process. See Review Process to learn more.
- To release an update, increase the number in the version field of the manifest.
Learn more about the Chrome Web Store Publish API here.
Uploading a package to create a new store item
Endpoint: https://www.googleapis.com/upload/chromewebstore/v1.1/items
Type: POST
Header Parameters:
$TOKEN: the access token
Body content: the package file to upload
Type the following example on the command line:
> curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-X POST \
-T $FILE_NAME \
-v \
https://www.googleapis.com/upload/chromewebstore/v1.1/items
For a full description of the insert method, see Items:Insert.
Uploading a package to update an existing store item
Endpoint: https://www.googleapis.com/upload/chromewebstore/v1.1/items/$ITEM_ID
Type: PUT
Header Parameters:
$TOKEN: the access token
Body content: the package file to upload
$ITEM_ID is the ID of the existing Web Store item.
> curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-X PUT \
-T $FILE_NAME \
-v \
https://www.googleapis.com/upload/chromewebstore/v1.1/items/$ITEM_ID
For a full description of the update method, see Items:Update.
Publishing an item to the public
Endpoint: https://www.googleapis.com/chromewebstore/v1.1/items/$ITEM_ID/publish
Type: POST
Header Parameters:
$TOKEN: the access token
> curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-X POST \
-v \
https://www.googleapis.com/chromewebstore/v1.1/items/$ITEM_ID/publish
For a full description of publish method, see Items:Publish.
Publishing an item to trusted testers
Endpoint: https://www.googleapis.com/chromewebstore/v1.1/items/$ITEM_ID/publish?publishTarget=trustedTesters
Type: POST
Header Parameters:
$TOKEN: the access token
> curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-X POST \
-v \
https://www.googleapis.com/chromewebstore/v1.1/items/$ITEM_ID/publish?publishTarget=trustedTesters
For a full description of the publish method, see Items:Publish.
Checking the upload status of an item
Endpoint: https://www.googleapis.com/chromewebstore/v1.1/items/$ITEM_ID?projection=DRAFT
Type: GET
Header Parameters:
$TOKEN: the access token
curl \
-H "Authorization: Bearer $TOKEN" \
-H "x-goog-api-version: 2" \
-H "Content-Length: 0" \
-H "Expect:" \
-X GET \
-v \
https://www.googleapis.com/chromewebstore/v1.1/items/$ITEM_ID?projection=DRAFT
Only projection=DRAFT is supported at this time.
For a full description of the get method, see Items:Get.