Search API Connector Documentation
Import eBay Data to Google Sheets
In this guide, we’ll walk through how to import eBay data directly into Google Sheets, using the API Connector add-on for Sheets.
eBay uses a non-standard implementation of OAuth so we'll get our token through some custom requests rather than using the OAuth manager.
- Before You Begin
- Part 1: Get Your eBay Client ID & Secret
- Part 2: Get Your Auth Code
- Part 3: Get Your Token
- Part 4: Get eBay Data in Sheets
- Part 5: Refresh the Access Token
- Part 6: API Documentation
Before You Begin
Click here to install the API Connector add-on from the Google Marketplace.
Part 1: Get your eBay Client ID & Secret
- Sign up for a developer account. It will take 1-2 business days to get approved.
- Log in to the eBay Developer site and navigate to Your Account > Application Keys . Name your application and click Create a keyset for either the Sandbox or Production environments, depending on the environment you're targeting.
- Note your Client ID and Client Secret
- One more step: for OAuth, we'll need to encode these values to Base 64 (i.e. basic authentication), so let's do that now. Enter your credentials in the format
client ID:client secretinto this form (i.e. your client ID, then a colon, and then your client secret).
The encoding script runs in your browser, and none of your credentials are seen or stored by this site.
- Copy the result and keep it handy. This will be referred to as
your_encoded_credentials, and we'll use this value later.
Part 2: Get Your Auth Code
Now that we have the encoded client ID & secret, let's get our auth code. We'll need to use the auth code within a few minutes of retrieving it, so if you'd prefer not to rush, you can set up (but not run) the token request in part 3 first.
- Navigate to the User Access Tokens section of the site.
- As before choose whether you'd like to access product or test environment
- Scroll down the page to the Get a Token from eBay via Your Application section. Click +Add eBay Redirect URL
- You'll be prompted to fill out some information about yourself or your company. Do so and click Save to return to the redirect URL form.
- Select OAuth. Leave the other fields blank. Click Save
- Now click Test Sign-In
- You'll be asked to log into eBay (if you aren't already), and will then see a code parameter in the URL bar starting with
v%5E1. Copy this value, it's our auth code.
- One more step: the code above is URL encoded, but we'll need to send back the URL-decoded value. Decode your code using your tool of choice, e.g. https://meyerweb.com/eric/tools/dencoder/. We'll call this
your_auth_code, and will use it shortly.
Part 3: Get Your Token
We now have all the pieces we need to get our token. We'll need to move a little quickly here as the code above is only valid for a few minutes.
In the configuration below, replace
your_encoded_credentials with your encoded client ID & secret from part 1, replace
your_auth_code with your decoded auth code, and replace
your_RuName with the RuName given to you in the redirect URL form (see screenshot).
- Open up Google Sheets and click Extensions > API Connector > Open
- Fill in the request form like this:
- Request URL:
- Request body:
- Hit Run and you should see your access token in cell A1. Finally! 🙂
Part 4: Get eBay Data in Sheets
You can see the full list of available endpoints and parameters in the API documentation, along with a nice API Explorer tool. Here's an example request. Substitute in the token value from the
access_token field (for convenience, I referenced the cell containing it).
The token will last for 2 hours, see the next section for how to refresh it after that.
- Request URL:
Part 5: Refresh the Access Token
The original token you retrieve will last for 7200 seconds, or 2 hours.
However, that same response also contains a refresh token that can be used to fetch new access tokens for 47304000 seconds (1.5 years). That means every time you need a new token, run the following request:
- Request URL:
- Request body:
This request will never change, as it always uses the same refresh_token from the original response. You can schedule it so that it always runs immediately before your data request, thus keeping your access active. In that data request, reference the cell containing the access token so it always plugs in the new token dynamically, and you won't need to update your requests again (for 1.5 years).
Part 6: API Documentation
Official API Documentation: https://developer.ebay.com/develop/apis/restful-apis
eBay API Explorer Tool: https://developer.ebay.com/my/api_test_tool?index=0