Google Apps Script
Add a GunSpec menu and custom cell functions to any Google Sheet. Live data, auto-refresh, zero setup beyond pasting the script.
Setup
Download the file using the button above
Open your Google Sheet
Go to Extensions > Apps Script
Delete any existing code in Code.gs and paste the entire contents of the downloaded file
Find the API_KEY constant and replace it:
const API_KEY = 'test_key';Click Save (Ctrl+S), then refresh the Google Sheet
A GunSpec menu appears in the menu bar
Custom Cell Functions
Use these directly in any cell - they return live data:
| Function | Example | Returns |
|---|---|---|
GUNSPEC_FIREARM | =GUNSPEC_FIREARM("m4a1-carbine", "weight_kg") | A single field value (e.g. 2.88) |
GUNSPEC_LIST | =GUNSPEC_LIST(20) | 2D array: name, manufacturer, caliber, country, year |
GUNSPEC_SEARCH | =GUNSPEC_SEARCH("carbine", 10) | 2D array of search results with headers |
Spill ranges: GUNSPEC_LIST and GUNSPEC_SEARCH return multi-row results that spill into adjacent cells. Place them in a cell with empty space below and to the right.
Menu Actions
| Action | What it does |
|---|---|
| Import Firearms | Creates a new sheet with all firearms (13 columns, auto-resized) |
| Import Firearm Detail | Prompts for a slug, creates a field/value detail sheet |
| Compare Firearms | Prompts for two slugs, creates a side-by-side comparison |
| Search Firearms | Prompts for a query, creates a results sheet |
Auto-Refresh on a Schedule
In the Apps Script editor, click the Triggers icon (clock) in the left sidebar
Click + Add Trigger
Choose function: importFirearms, event source: Time-driven, frequency: every hour/day
A fresh sheet with updated data is created on each run


