Skip to content

SellerLegend Google Sheets API Integration Guide

Proof of Concept

This integration is a Proof-of-Concept. It is not part of the SellerLegend product development roadmap and does not come with official support or SLA guarantees.

Prerequisites

  • Google account with Sheets access
  • SellerLegend account with API credentials
  • 15-20 minutes for complete setup

Step 1: Create Google Sheet

  1. Navigate to sheets.google.com
  2. Create a new blank spreadsheet
  3. Rename it to "SellerLegend Data Integration"

Step 2: Add Integration Script

  1. Select Extensions → Apps Script
  2. Clear the default code
  3. Paste the contents of google-sheets-oauth-integration.js
  4. Save project as "SellerLegend Integration"

Step 3: Deploy as Web App

  1. Click Deploy → New deployment
  2. Select Web app from the gear menu
  3. Configure settings:
    • Description: "OAuth Callback Handler"
    • Execute as: Your email
    • Access: Anyone
  4. Authorize the app through Google account verification
  5. Copy the Web App URL (format: https://script.google.com/macros/s/[ID]/exec)
  6. Verify the "SellerLegend OAuth" menu appears in your sheet

Step 4: Create SellerLegend OAuth Client

  1. Login to SellerLegend → Account → Developers
  2. Click Create New Client
  3. Fill in the form:
    • Name: "Google Sheets Integration"
    • Redirect URL: Paste your Web App URL from Step 3
    • Keep "Confidential" checked
  4. Save your Client ID and Client Secret securely

Step 5: Connect to SellerLegend

5.1 Setup OAuth Settings

  1. Click SellerLegend OAuth → 1. Setup OAuth
  2. Go to the new "OAuth Settings" sheet tab
  3. Fill in the required cells:
    • B2: Client ID
    • B3: Client Secret
    • B4: https://app.sellerlegend.com
    • B5: Web App URL (redirect URI)

5.2 Get Authorization

  1. Click SellerLegend OAuth → 2. Get Authorization Code
  2. Click the authorization link, login to SellerLegend
  3. Click Authorize
  4. Copy the authorization code displayed
  5. Paste the code in OAuth Settings cell B8

5.3 Exchange for Token

  1. Click SellerLegend OAuth → Exchange Code for Token
  2. Token auto-stores

5.4 Test Connection

  1. Click SellerLegend OAuth → Test API Connection
  2. Confirm user info displays

Step 6: Fetch Accounts

  1. Click SellerLegend OAuth → Get Accounts
  2. A new "Accounts" tab displays all your marketplace accounts

Step 7: Setup Sales Statistics Dashboard

  1. Click SellerLegend OAuth → Setup Sales Stats Dashboard
  2. A new "Sales Stats Config" sheet is created

Configuration Parameters

ParameterPurposeExamples
AccountWhich account to queryStore name from dropdown
View ByData grouping dimensionproduct / date
Group ByAggregation methodSKU, ASIN, Product
Start DateQuery start date2024-01-01
End DateQuery end date2024-01-31
CurrencyDisplay currencyUSD, GBP, EUR
Per PageResults per fetch500, 1000, 2000
Filter ByOptional filter typesku / asin or blank
Filter ValueFilter parameterSKU12345
Sales ChannelChannel filteramazon / non-amazon / blank
Target SheetOutput sheet name"Product Sales"
PageResults page number1, 2, 3
Write ModeData handlingOverwrite / Append

Fetching Data

  1. Configure Sales Stats Config with your desired parameters
  2. Click SellerLegend OAuth → Fetch Sales Statistics
  3. Wait for completion message
  4. View the populated target sheet with SKUs, ASINs, units sold, revenue, costs, and profit

Security Warnings

DANGER

Your Client ID, Client Secret, Authorization Code, Access Token, and Refresh Token are highly confidential. Never share them with anyone. These credentials are stored unencrypted within your Google Sheet.

Treat these credentials with maximum security:

  • Restrict access to the sheet
  • Remove credentials when they are no longer needed

Troubleshooting

IssueSolution
"No access token found"Repeat Step 5 to obtain a new token
"Token expired"Click Refresh Access Token or get a new token
"No data found"Verify date range contains sales; check account/filter settings
"Failed to fetch accounts"Confirm token validity via test; ensure accounts exist

Access execution logs via Extensions → Apps Script → Executions for diagnostic information.

Best Practices

  • Keep your Client Secret private; never share the OAuth Settings sheet
  • Use smaller date ranges for faster results
  • Create separate sheets for different reports
  • Refresh tokens before expiration (every 2 weeks)