• Knowledge Base
  • Release Notes
  • Glossary
  • Knowledge Base
  • Release Notes
  • Glossary
Home/KnowledgeBase/Integrations/SellerLegend Google Sheets API Integration Guide

SellerLegend Google Sheets API Integration Guide

29 views 4

What This KB Article Is About

A step-by-step guide for connecting SellerLegend with Google Sheets to automatically pull your Sales Statistics data.

Please note: This feature is a Proof-of-Concept only. It is not part of the SellerLegend product development roadmap and is not officially supported by our development or support teams. As such, no Service Level Agreement applies, and we cannot guarantee fixes for bugs or malfunctions.

We welcome feedback and ideas for improvement; however, any updates or enhancements will be considered solely at our discretion and implemented only if time and resources allow.

What You’ll Need

Before starting, make sure you have:

  • A Google account (for Google Sheets)

  • A SellerLegend account with API access enabled

  • About 15–20 minutes to complete the setup


Step 1: Create Your Google Sheet

  1. Open Google Sheets

    • Go to sheets.google.com

    • Click the “+” button to create a new blank spreadsheet

  2. Name Your Spreadsheet

    • Click on “Untitled spreadsheet” at the top

    • Name it as “SellerLegend Data Integration”

    • The sheet will auto-save


Step 2: Add the Integration Script

  1. Open Apps Script Editor

    • In your Google Sheet, click Extensions in the menu

    • Select Apps Script

    • A new tab will open with a code editor

  2. Clear Default Code

    • You’ll see some default code like function myFunction() {}

    • Select all the text (Ctrl+A on Windows, Cmd+A on Mac)

    • Delete it

  3. Add the Integration Script

    • Copy the entire contents of google-sheets-oauth-integration.js

    • Paste it into the Apps Script editor

    • Click the 💾 Save icon (or press Ctrl+S / Cmd+S)

    • Name the project “SellerLegend Integration” when prompted


Step 3: Deploy as Web App

This step creates a URL that SellerLegend will use to send authorization codes back to your sheet.

  1. Start Deployment

    • In the Apps Script editor, click the Deploy button (top right)

    • Select New deployment

  2. Configure Deployment

    • Click the gear icon ⚙️ next to Select type

    • Choose Web app

    • Fill in these settings:

      • Description: OAuth Callback Handler

      • Execute as: Me (your email will show here)

      • Who has access: Anyone

  3. Deploy and Copy URL

    • Click Deploy

    • Authorise the app when prompted (select account → Advanced → Continue)

    • A modal appears “The web app requires you to authorise access to your data.” with an “Authorise Access” button.
    • Click on the button
    • A modal appears to select your Google account. Select your account of choice.
    • A modal appears “Google hasn’t verified this app”
    • Click on “Advanced”
    • Click on “Go to SellerLegend Integration (unsafe)”
    • A modal appears “SellerLegend Integration wants to access your Google Account”
    • Click on “Allow”
    • ⚠️ IMPORTANT: A window will appear with your Web App URL

    • Copy this entire URL — it looks like:

      https://script.google.com/macros/s/AKfycbw.../exec
    • Save this URL in a notepad — you’ll need it in Step 4

    • Click Done

  4. Return to Your Google Sheet

    • Close the Apps Script tab

    • Refresh the Google Sheet (F5 or Cmd+R)

    • You should now see a new menu item: SellerLegend OAuth


Step 4: Create SellerLegend OAuth Client

Now we’ll create credentials in SellerLegend that allow Google Sheets to access your data.

  1. Login to SellerLegend

    • Go to your SellerLegend Account Settings
    • Navigate to Account → Developers

    • Or go directly to: https://app.sellerlegend.com/account/developers

  2. Create New OAuth Client

    • Click Create New Client

    • Fill in the form:

      • Name: Google Sheets Integration

      • Redirect URL: Paste the Web App URL from Step 3 (the `https://script.google.com/macros/s/…/exec` URL)

      • Leave the box Confidential ticked

    • Click Create

  3. Copy Your Credentials

    • After creation, note down:

      • Client ID (usually a number like “2” or “3”)

      • Client Secret a long string of random characters

    • Copy both of these. Keep this window open for later reference or save in notepad

⚠️ IMPORTANT SECURITY NOTICE
Your Client ID, Client Secret, Authorization Code, Access Token, Refresh Token, and similar credentials are highly confidential. Never share them with anyone.

These credentials are stored unencrypted within your Google Sheet and grant the same level of access as your SellerLegend password. If exposed, your account and data could be compromised.

Treat this information with the highest level of security — restrict access to the sheet, store backups securely, and remove credentials when they are no longer needed.


Step 5: Connect to SellerLegend

Now we’ll connect your Google Sheet to SellerLegend using the credentials.

5.1. Setup OAuth in Google Sheets

1. Initialize OAuth Settings

    • In your Google Sheet menu, click SellerLegend OAuth menu item
    • Click 1. Setup OAuth
    • Click OK when the setup complete message appears
    • A new sheet tab called “OAuth Settings” will be created

2. Enter Your Credentials

    • Go to the OAuth Settings sheet tab
    • Find these cells and fill them in:
      • Cell B2 (Client ID): Enter your Client ID from SellerLegend (e.g., “2”)
      • Cell B3 (Client Secret): Enter your Client Secret from SellerLegend
      • Cell B4 (Base URL): Should already say `https://app.sellerlegend.com`
      • Leave other fields as they are

5.2 Add Redirect URI

  1. In the OAuth Settings sheet

    • Find Cell B5 (Redirect URI)
    • Paste the same Web App URL you copied in Step 3.3
    • This should be the `https://script.google.com/macros/s/…/exec` URL

5.3 Get Authorization

  1.  Start Authorization
    • Click SellerLegend OAuth menu
    • Click 2, Get Authorization Code
    • A dialog will appear with a link “Open Authorization Page”
  2.  Authorize Access
    • Click the **”🔗 Open Authorization Page”** link
    • This opens SellerLegend in a new tab
    • Login if prompted
    • Click Authorize to grant access
    • You’ll see an authorization code on the screen
  3. Copy the Authorization Code
    • Copy the entire authorization code shown
    • Go back to your Google Sheet
    • Dismiss the Oauth Authorization box (click on X)
    • Go to the OAuth Settings sheet tab
    • Paste the code in cell B8 (Authorization Code row)

5.4 Get Your Access Token

  1. Click SellerLegend OAuth → Exchange Code for Token

  2. Token details will be stored automatically

5.5 Test the Connection

  1. Click SellerLegend OAuth menu

  2. Click Test API Connection

  3. If you see your user info (ID, Name, email, etc.) — ✅ success


Step 6: Fetch Your Accounts

Before fetching sales data, you need to get your SellerLegend accounts (marketplaces)

  1. Click SellerLegend OAuth

  2. Click on Get Accounts

  3. Wait a moment while it fetches your accounts
  4. You’ll see a success message showing how many accounts were found
  5. Check your accounts
    • A new tab Accounts will appear with all your SellerLegend accounts, including:
      • Account title

      • Marketplace (US, UK, etc.)

      • Currencies

      • Seller IDs

  6. Click on OK to dismiss the account retrieval box

Step 7: Setup Sales Statistics Dashboard

Now let’s configure the dashboard to fetch sales data.

  1. Create Configuration

    • Click SellerLegend OAuth

    • Click on Setup Sales Stats Dashboard

    • Click OK when setup is complete
    • A new sheet Sales Stats Config sheet will appear

  2. Understanding the configuration

The Sales Stats Config sheet has these settings:

Parameter What It Means Example
Account Which SL account to use Your store name
View By Group data by product/date product / date
Group By How to group the data SKU, ASIN, Product
Start Date Start date 2024-01-01
End Date End date 2024-01-31
Currency Currency for amounts USD, GBP, EUR
Per Page how many Results per fetch 500, 1000, 2000
Filter By Optional filter type sku / asin or leave empty
Filter Value Value to filter for SKU12345
Sales Channel amazon / non-amazon / blank amazon
Target Sheet Where to put the data Product Sales
Page Which page of results 1, 2, 3
Write Mode How to handle existing data Overwrite or Append

Using the Sales Stats Dashboard

Basic Usage: Fetch All Products for Last 30 Days

  • Configure Settings

    • In Sales Stats Config sheet:
      • Account: Select your account from dropdown
      • View By: Keep as “product”
      • Group By: Keep as “Product”
      • Start Date: Already set to 30 days ago
      • End Date: Already set to today
      • Target Sheet: Type “Product Sales” (or any sheet name)
      • Write Mode: Select “Overwrite”
  • Fetch the Data
    • Click SellerLegend OAuth menu
    • Click Fetch Sales Statistics
    • Wait while data is fetched (may take 10-30 seconds)
    • Success message will show how many rows were fetched
  • View Your Data
    Click on the sheet tab with your target sheet name
    You’ll see all your products with:

    • SKUs and ASINs
    • Units sold
    • Revenue and costs
    • Profit margins

Advanced Usage Examples

Example 1: Get Daily Sales for Specific Product

  1. Configure:
    • View By: “date”
    • Group By: “Date” (will change automatically)
    • Filter By: “SKU”
    • Filter Value: Your product SKU
    • Target Sheet: “Daily Sales”
  2. Fetch:
    • Click “Fetch Sales Statistics”

Example 2: Combine Multiple Pages of Data

1. For Page 1:

    • Set Page:  “1”
    • Set Write Mode: “Overwrite”
    • Fetch the data

2. For Page 2:

    • Set Page: “2”
    • Set Write Mode: “Append”
    • Fetch the data
    • Page 2 will be added below Page 1

Example 3: Compare Different Time Periods

1. January Data:

    • Set dates to January
    • Target Sheet: “Monthly Comparison”
    • Write Mode: “Overwrite”
    • Fetch

2. February Data:

    • Change dates to February
    • Same target sheet
    • Write Mode: “Append”
    • Fetch
      • Both months now in same sheet for comparison

Understanding Write Modes

  • Overwrite: Clears the target sheet and adds fresh data
    • Use for: Single queries, starting fresh
  • Append: Adds new data below existing data
    • Use for: Multiple pages, combining date ranges, building reports

Tips for Success

  • Start Small
    • Test with short date ranges first (7 days)
    • Once working, expand to longer periods
  • Use Filters Wisely
    • Filter by SKU to track specific products
    • Filter by ASIN to group variations
  • Save Different Configs
    • Create multiple sheets with different saved configurations
    • Copy the Sales Stats Config sheet to save different setups
  • Check Your Data
    • The TOTAL row at bottom shows sums
    • Use Google Sheets charts to visualize trends

 


Troubleshooting

Common Issues and Solutions

  1. “No access token found”

    • Solution:

      • Run through Step 5 again to get a new token

  2. “Token expired”

    • Solution:
      • Click SellerLegend OAuth → Refresh Access Token
      • Or get a new token using Get New Access Token (Client Credentials)
  3. “No data found”

    • Check:

      • Date range has sales data

      • Account selection is correct

      • Filters aren’t too restrictive→ Check date range, filters

  4. “Failed to fetch accounts”
    • Check:
      • Token is valid (test connection first)
      • You have accounts in SellerLegend
  5. Data looks wrong
    • Check:
      • Currency setting matches your needs
      • Date range is correct
      • View By and Group By match your intent

Getting Help:

  1. Check Logs
    • In Google Sheets: Extensions → Apps Script
    • Click Executions (left sidebar)
      • Click on recent execution to see detailed logs
  2. Token Issues
    • Tokens expire after 15 days
    • Set a reminder to refresh monthly
    • Or use Client Credentials token (doesn’t expire)
  3. Need More Help?
    • Check your SellerLegend API documentation
    • Contact SellerLegend support for API issues (No guaranteed SLA as this is a proof of concept/example)
    • For script issues, check the error messages in logs

Best Practices

  1. Security
    • Never share your Client Secret
    • Don’t share the OAuth Settings sheet with others
    • Keep your Google Sheet private or view-only for others
  2. Performance
    • Fetch smaller date ranges for faster results
    • Use filters to reduce data volume
    • 500 per page is usually fastest
  3. Organization
    • Create separate sheets for different reports
    • Use clear target sheet names
    • Document your configurations
  4. Maintenance
    • Refresh token before it expires (every 2 weeks)
    • Check for script updates periodically
    • Keep your configurations backed up

Congratulations! 🎉

You’ve successfully connected SellerLegend to Google Sheets! You can now:

  1. Pull sales data automatically into Google Sheets

  2. Create custom reports

  3. Track performance over time

  4. Export data for further analysis

Quick Reference Card

Daily Tasks:

  1. Open sheet

  2. Adjust date range

  3. Fetch data

  4. Review

Weekly Tasks:

  1. Refresh token (if needed)

  2. Check errors

  3. Update configs as needed

Google Sheets Menu Options Quick Guide:

  1. Setup OAuth – First time setup only

  2. Get Authorization Code – Start auth process

  3. Exchange Code for Token – Complete auth

  4. Test API Connection – Verify it works

  5. Get Accounts – Fetch your accounts

  6. Setup Sales Stats Dashboard – Create config sheet

  7. Fetch Sales Statistics – Get your data!

  8. Refresh Access Token – Renew expired token


Last updated: 13 August 2025
Script version: 0.1

Was this helpful?

4 Yes  No

No luck finding what you need? Contact Us

  How Do I Use The SellerLegend API?

  • Copyright 2025 SellerLegend Limited. All Rights Reserved.