Documentation Index Fetch the complete documentation index at: https://docs.linkup.so/llms.txt
Use this file to discover all available pages before exploring further.
This guide shows how to combine the Linkup API with Google Sheets to build an automated peer comparison tool. Useful for investors, market analysts, and business strategists who need accurate competitive intelligence without standing up a custom backend.
Don’t walk away if you’re not a developer! This tutorial is designed to be accessible for everyone - no coding experience required. Just follow our simple copy-paste instructions and clear screenshots to set up your own peer comparison tool in minutes.
Prerequisites
Before starting, ensure you have:
A Google account
A Linkup API key (required for making requests)
Get your API key Create a Linkup account for free to get your API key.
Setup guide
Step 1: open Google Sheets
Open a new Google Sheet
Name it “Company Peer Finder” or any name you prefer
Step 2: access Apps Script
Click on “Extensions” in the menu bar
Select “Apps Script” from the dropdown menu
1: Accessing Apps Script through the Extensions menu
Step 3: set up the script
In the Apps Script editor, delete any existing code
Copy and paste the following script:
// Google Apps Script for Company Peer Finder with direct Linkup integration
// This script uses Linkup API to find peer companies based on input companies
// Configuration - replace with your actual Linkup API key
const LINKUP_API_KEY = "YOUR_API_KEY" ; // Replace with your Linkup API key
const LINKUP_API_URL = "https://api.linkup.so/v1" ; // Linkup API base URL
// Create the menu when the spreadsheet opens
function onOpen () {
const ui = SpreadsheetApp . getUi ();
ui . createMenu ( 'Peer Finder' )
. addItem ( 'Extract Common Characteristics' , 'extractCommonCharacteristics' )
. addItem ( 'Find Peer Companies' , 'findPeerCompanies' )
. addToUi ();
}
// Function to extract common characteristics from input companies
function extractCommonCharacteristics () {
const ss = SpreadsheetApp . getActiveSpreadsheet ();
const inputSheet = ss . getSheetByName ( 'Input Companies' );
const charSheet = ss . getSheetByName ( 'Characteristics' );
if ( ! inputSheet || ! charSheet ) {
setupSpreadsheet ();
return ;
}
const companies = inputSheet . getRange ( 'A2:A6' ). getValues (). flat (). filter ( Boolean );
if ( companies . length === 0 ) {
SpreadsheetApp . getUi (). alert ( 'Please enter at least one company name in the Input Companies sheet.' );
return ;
}
const characteristics = [];
for ( const company of companies ) {
const response = fetchCompanyData ( company );
if ( response && response . characteristics ) {
characteristics . push ( ... response . characteristics );
}
}
// Count frequency of each characteristic
const charCount = {};
characteristics . forEach ( char => {
charCount [ char ] = ( charCount [ char ] || 0 ) + 1 ;
});
// Sort by frequency
const sortedChars = Object . entries ( charCount )
. sort (( a , b ) => b [ 1 ] - a [ 1 ])
. map (([ char , count ]) => [ char , count , false ]);
// Update characteristics sheet
charSheet . clear ();
charSheet . getRange ( 1 , 1 , 1 , 3 ). setValues ([[ 'Characteristic' , 'Frequency' , 'Use for Search' ]]);
if ( sortedChars . length > 0 ) {
charSheet . getRange ( 2 , 1 , sortedChars . length , 3 ). setValues ( sortedChars );
}
}
// Function to find peer companies based on selected characteristics
function findPeerCompanies () {
const ss = SpreadsheetApp . getActiveSpreadsheet ();
const charSheet = ss . getSheetByName ( 'Characteristics' );
const resultsSheet = ss . getSheetByName ( 'Peer Companies' );
if ( ! charSheet || ! resultsSheet ) {
setupSpreadsheet ();
return ;
}
const selectedChars = charSheet . getRange ( 'B2:B' ). getValues ()
. flat ()
. map (( checked , i ) => checked ? charSheet . getRange ( i + 2 , 1 ). getValue () : null )
. filter ( Boolean );
if ( selectedChars . length === 0 ) {
SpreadsheetApp . getUi (). alert ( 'Please select at least one characteristic to use for finding peer companies.' );
return ;
}
const peers = findPeersByCharacteristics ( selectedChars );
// Update results sheet
resultsSheet . clear ();
resultsSheet . getRange ( 1 , 1 , 1 , 4 ). setValues ([[ 'Company' , 'Match Score' , 'Industry' , 'Size' ]]);
if ( peers . length > 0 ) {
resultsSheet . getRange ( 2 , 1 , peers . length , 4 ). setValues ( peers );
}
}
// Helper function to fetch company data from Linkup API
function fetchCompanyData ( companyName ) {
const options = {
method: 'GET' ,
headers: {
'Authorization' : `Bearer ${ LINKUP_API_KEY } ` ,
'Content-Type' : 'application/json'
}
};
try {
const response = UrlFetchApp . fetch ( ` ${ LINKUP_API_URL } /companies/search?q= ${ encodeURIComponent ( companyName ) } ` , options );
return JSON . parse ( response . getContentText ());
} catch ( error ) {
console . error ( `Error fetching data for ${ companyName } :` , error );
return null ;
}
}
// Helper function to find peers based on characteristics
function findPeersByCharacteristics ( characteristics ) {
const options = {
method: 'POST' ,
headers: {
'Authorization' : `Bearer ${ LINKUP_API_KEY } ` ,
'Content-Type' : 'application/json'
},
payload: JSON . stringify ({ characteristics })
};
try {
const response = UrlFetchApp . fetch ( ` ${ LINKUP_API_URL } /companies/peers` , options );
return JSON . parse ( response . getContentText ());
} catch ( error ) {
console . error ( 'Error finding peers:' , error );
return [];
}
}
// Function to set up the initial spreadsheet structure
function setupSpreadsheet () {
const ss = SpreadsheetApp . getActiveSpreadsheet ();
// Create or clear sheets
const sheets = [ 'Input Companies' , 'Characteristics' , 'Peer Companies' ];
sheets . forEach ( sheetName => {
let sheet = ss . getSheetByName ( sheetName );
if ( ! sheet ) {
sheet = ss . insertSheet ( sheetName );
}
sheet . clear ();
});
// Set up Input Companies sheet
const inputSheet = ss . getSheetByName ( 'Input Companies' );
inputSheet . getRange ( 'A1' ). setValue ( 'Enter up to 5 company names below:' );
inputSheet . getRange ( 'A2:A6' ). setBackground ( '#f3f3f3' );
// Set up Characteristics sheet
const charSheet = ss . getSheetByName ( 'Characteristics' );
charSheet . getRange ( 'A1:C1' ). setValues ([[ 'Characteristic' , 'Frequency' , 'Use for Search' ]]);
charSheet . getRange ( 'C2:C' ). setDataValidation ( SpreadsheetApp . newDataValidation ()
. requireCheckbox ()
. build ());
// Set up Peer Companies sheet
const resultsSheet = ss . getSheetByName ( 'Peer Companies' );
resultsSheet . getRange ( 'A1:D1' ). setValues ([[ 'Company' , 'Match Score' , 'Industry' , 'Size' ]]);
// Hide unused sheets
ss . getSheets (). forEach ( sheet => {
if ( ! sheets . includes ( sheet . getName ())) {
sheet . hideSheet ();
}
});
SpreadsheetApp . getUi (). alert ( 'Spreadsheet setup complete! You can now enter company names and use the Peer Finder menu.' );
}
Replace YOUR_API_KEY with your actual Linkup API key
If you don’t have an API key:
Go to app.linkup.so
Create an account or sign in
Navigate to your API settings
Copy your API key
Step 5: save the script
Click the “Save” button (or press Ctrl+S/Cmd+S)
Step 6: authorize the script
When prompted, authorize the script to:
Access your Google Sheets
Make external API calls
Display dialogs
2: The Google authorization screen
Step 7: initialize the spreadsheet
Click “Run” and select “SetupSpreadsheet”
3: Selecting SetupSpreadsheet
Step 8: verify setup
Look for a confirmation popup in your main sheet
4: The confirmation popup
Click “Run” and select “OnOpen”
5: Selecting OnOpen
Using the peer finder
Step 1: enter companies
Go to the “Input Companies” sheet
Enter up to 5 companies in cells A2-A6
Make sure to enter the full company names
Click on the “Peer Finder” menu
Select “Extract Common Characteristics”
Wait for the process to complete
Review the extracted characteristics in the “Characteristics” sheet
Step 3: select characteristics
In the “Characteristics” sheet, review the list of common characteristics
Use the checkboxes in column B to select which characteristics to use for finding peer companies
Select at least one characteristic
Step 4: find peer companies
Click on the “Peer Finder” menu again
Select “Find Peer Companies”
Wait for the process to complete
Review the list of peer companies in the “Peer Companies” sheet
Step 5: review and refine
Review the list of peer companies
If needed, go back to Step 3 and adjust your characteristic selections
Run the peer finder again with different characteristics
For more detailed examples and use cases, check out our Prompt Catalog .