You do not need to be a developer to extract local business data from search results. With curl and a Scavio API key, you can pull business names, ratings, addresses, and phone numbers for any location. Pipe the output to a JSON file, open it in a spreadsheet tool, and you have a local business database. Each search costs $0.005. This tutorial walks through the entire process using only terminal commands and free tools.
Prerequisites
- A terminal with curl installed (macOS/Linux built-in, Windows via Git Bash)
- A Scavio API key from scavio.dev
- A spreadsheet tool (Google Sheets, Excel, or LibreOffice)
- jq installed for JSON processing (optional but recommended)
Walkthrough
Step 1: Run your first local business search
Use curl to POST a search query to the Scavio API. The response includes local pack results with business names, ratings, and addresses.
# Set your API key
export SCAVIO_API_KEY="your_key_here"
# Search for local businesses
curl -s -X POST https://api.scavio.dev/api/v1/search \
-H "x-api-key: $SCAVIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "best pizza in Chicago", "country_code": "us", "num_results": 10}' \
| python3 -m json.tool
# With jq for cleaner output
curl -s -X POST https://api.scavio.dev/api/v1/search \
-H "x-api-key: $SCAVIO_API_KEY" \
-H "Content-Type: application/json" \
-d '{"query": "best pizza in Chicago", "country_code": "us", "num_results": 10}' \
| jq '.local_results[] | {name: .title, rating: .rating, address: .address}'Step 2: Extract business data to a JSON file
Save search results to files for each business category. Run multiple searches to build a comprehensive database.
# Search multiple categories and save results
for category in "restaurants" "dentists" "plumbers" "hair salons"; do
echo "Searching: $category in Chicago"
curl -s -X POST https://api.scavio.dev/api/v1/search \
-H "x-api-key: $SCAVIO_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"query\": \"$category in Chicago IL\", \"country_code\": \"us\", \"num_results\": 10}" \
> "${category}_chicago.json"
sleep 1 # Rate limiting
done
# Verify the files
for f in *_chicago.json; do
count=$(jq '.local_results | length' "$f" 2>/dev/null || echo 0)
echo "$f: $count local results"
doneStep 3: Convert JSON to CSV using jq
Transform the JSON results into CSV format that any spreadsheet can import. Extract the fields you need: name, rating, reviews, address, phone.
# Convert a single file to CSV
echo "name,rating,reviews,address,phone" > chicago_businesses.csv
for f in *_chicago.json; do
category=$(echo "$f" | sed 's/_chicago.json//')
jq -r --arg cat "$category" \
'.local_results[]? | [.title // "", .rating // "", .reviews // "", .address // "", .phone // "", $cat] | @csv' \
"$f" >> chicago_businesses.csv 2>/dev/null
done
# Preview the CSV
head -10 chicago_businesses.csv
echo ""
wc -l chicago_businesses.csv | awk '{print $1 - 1, "businesses extracted"}'Step 4: Build a simple bash script for repeatable extraction
Wrap the entire process in a reusable script. Pass in a city and get a CSV of local businesses.
#!/bin/bash
# local_business_extract.sh - Extract local businesses for any city
# Usage: ./local_business_extract.sh "Austin TX"
CITY="${1:-Austin TX}"
SAFE_CITY=$(echo "$CITY" | tr ' ' '_' | tr '[:upper:]' '[:lower:]')
OUTPUT="${SAFE_CITY}_businesses.csv"
CATEGORIES=("restaurants" "dentists" "plumbers" "electricians" "hair salons")
echo "Extracting businesses in $CITY"
echo "name,category,rating,reviews,address" > "$OUTPUT"
for cat in "${CATEGORIES[@]}"; do
echo " Searching: $cat"
RESULT=$(curl -s -X POST https://api.scavio.dev/api/v1/search \
-H "x-api-key: $SCAVIO_API_KEY" \
-H "Content-Type: application/json" \
-d "{\"query\": \"$cat in $CITY\", \"country_code\": \"us\", \"num_results\": 10}")
echo "$RESULT" | jq -r --arg cat "$cat" \
'.local_results[]? | [.title // "", $cat, .rating // "", .reviews // "", .address // ""] | @csv' \
>> "$OUTPUT" 2>/dev/null
sleep 1
done
TOTAL=$(tail -n +2 "$OUTPUT" | wc -l | tr -d ' ')
COST=$(echo "${#CATEGORIES[@]} * 0.005" | bc)
echo "Done: $TOTAL businesses saved to $OUTPUT"
echo "Cost: \$$COST (${#CATEGORIES[@]} searches at \$0.005 each)"Python Example
import os, requests, csv
SCAVIO_KEY = os.environ['SCAVIO_API_KEY']
H = {'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json'}
def extract_businesses(city, categories):
all_biz = []
for cat in categories:
resp = requests.post('https://api.scavio.dev/api/v1/search', headers=H,
json={'query': f'{cat} in {city}', 'country_code': 'us', 'num_results': 10})
for r in resp.json().get('local_results', []):
all_biz.append({'name': r.get('title',''), 'category': cat,
'rating': r.get('rating',''), 'address': r.get('address','')})
with open(f'{city.replace(" ","_").lower()}.csv', 'w', newline='') as f:
w = csv.DictWriter(f, fieldnames=['name','category','rating','address'])
w.writeheader()
w.writerows(all_biz)
print(f'Exported {len(all_biz)} businesses')
extract_businesses('Austin TX', ['restaurants', 'dentists'])JavaScript Example
const SCAVIO_KEY = process.env.SCAVIO_API_KEY;
async function extractBusinesses(city, categories) {
const all = [];
for (const cat of categories) {
const resp = await fetch('https://api.scavio.dev/api/v1/search', {
method: 'POST',
headers: { 'x-api-key': SCAVIO_KEY, 'Content-Type': 'application/json' },
body: JSON.stringify({ query: `${cat} in ${city}`, country_code: 'us', num_results: 10 })
});
const local = (await resp.json()).local_results || [];
local.forEach(r => all.push({ name: r.title, category: cat, rating: r.rating, address: r.address }));
}
console.log(`Found ${all.length} businesses in ${city}`);
all.forEach(b => console.log(` ${b.name} (${b.rating}) - ${b.category}`));
}
extractBusinesses('Austin TX', ['restaurants', 'dentists']);Expected Output
Extracting businesses in Austin TX
Searching: restaurants
Searching: dentists
Searching: plumbers
Searching: electricians
Searching: hair salons
Done: 32 businesses saved to austin_tx_businesses.csv
Cost: $0.025 (5 searches at $0.005 each)
name,category,rating,reviews,address
"Franklin Barbecue",restaurants,4.8,4521,"900 E 11th St, Austin, TX"
"Uchi Austin",restaurants,4.7,2103,"801 S Lamar Blvd, Austin, TX"