Google sheets api coordinator

From masharratt/claude-flow-novice · View interactive version

Google sheets api coordinator is an AI agent skill from the GitHub repository masharratt/claude-flow-novice. Manages Google Sheets API calls with rate limiting and quota enforcement

How to use this skill

Skill file

Google Sheets API Coordinator Skill

Purpose

Manages and coordinates Google Sheets API calls with automatic rate limiting, quota tracking, and batch operation support. Prevents quota exhaustion, enforces API rate limits, and provides automatic retry logic with exponential backoff.

Problem Solved

Google Sheets API has strict quotas (300 requests/min for most users). Without coordination, multiple agents making concurrent API calls quickly exceed limits, causing cascading failures. This skill provides centralized quota management with rate limiting and batch operations enabling safe parallel execution.

When to Use

Interface

Primary Script: `api-call.sh`

Required Parameters:

Optional Parameters:

Usage:

# Single API call with rate limiting
./.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh \
  --api-endpoint "spreadsheets.values:get" \
  --spreadsheet-id abc123def456

# Batch operation
./.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh \
  --api-endpoint "spreadsheets.values:batchUpdate" \
  --spreadsheet-id abc123def456 \
  --batch-size 100 \
  --payload '{"data": [...]}'

# With custom quota limit and retries
./.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh \
  --api-endpoint "spreadsheets:create" \
  --spreadsheet-id abc123def456 \
  --quota-limit 60 \
  --max-retries 5

Rate Limiting Strategy

Quota Management

Rate Limit Handling

# Request rate tracking
./.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh \
  --quota-limit 60  # Custom limit for restricted account

Quota State Format

{
  "quota_window": {
    "start_time": "2025-11-18T10:00:00Z",
    "end_time": "2025-11-18T10:01:00Z",
    "requests_made": 45,
    "quota_limit": 300,
    "available_requests": 255,
    "time_until_reset_seconds": 42
  },
  "spreadsheet_quota": {
    "spreadsheet_id": "abc123def456",
    "requests_this_minute": 12,
    "average_response_time_ms": 250
  }
}

Output Format

{
  "success": true,
  "confidence": 0.97,
  "api_call": {
    "endpoint": "spreadsheets.values:get",
    "method": "GET",
    "status_code": 200
  },
  "quota_usage": {
    "requests_made": 1,
    "quota_remaining": 299,
    "rate_limited": false,
    "next_request_delay_ms": 100
  },
  "response": {
    "data": {...}
  },
  "metrics": {
    "execution_time_ms": 245,
    "retries_attempted": 0
  },
  "deliverables": ["api_response"],
  "errors": []
}

Error Handling

Automatic retry logic with exponential backoff:

{
  "error_code": "RATE_LIMIT_EXCEEDED",
  "status_code": 429,
  "action": "backoff",
  "wait_time_ms": 2000,
  "retry_attempt": 1,
  "max_retries": 3
}

Error Scenarios

  1. QUOTA_EXCEEDED - Request would exceed quota, delayed
  2. RATE_LIMIT - Too many requests in window, backoff applied
  3. TIMEOUT - Request timeout, automatic retry
  4. INVALID_API_KEY - Authentication failed, fatal
  5. MALFORMED_REQUEST - Invalid request structure, fatal
  6. SERVER_ERROR - 5xx errors, retry with backoff

Integration with CFN Loop

Loop 3 Agents (Implementation)

Coordinate API calls with automatic rate limiting:

# Make API call with automatic quota management
RESPONSE=$(./.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh \
  --api-endpoint "spreadsheets.values:get" \
  --spreadsheet-id "$SHEET_ID" \
  --quota-limit 300)

STATUS=$(echo "$RESPONSE" | jq -r '.success')
REMAINING=$(echo "$RESPONSE" | jq -r '.quota_usage.quota_remaining')

if [ "$STATUS" = "true" ]; then
  echo "API call successful, $REMAINING requests remaining"
else
  echo "API call failed"
fi

Batch Operations

# Batch update with automatic batching
./.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh \
  --api-endpoint "spreadsheets.values:batchUpdate" \
  --spreadsheet-id "$SHEET_ID" \
  --batch-size 100 \
  --payload "$BATCH_DATA"

Multi-Agent Coordination

All agents share quota pool:

# Agent 1 makes call (uses 1 of 300)
AGENT1=$(./.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh ...)

# Agent 2 makes call (automatically delayed to respect shared quota)
AGENT2=$(./.claude/cfn-extras/skills/google-sheets-api-coordinator/api-call.sh ...)

# Both complete without quota exhaustion

Success Criteria

Best Practices

  1. Always use coordinator - Never call API directly
  2. Batch when possible - Reduce total requests
  3. Share quota pool - Don't duplicate tracking
  4. Monitor quota - Log quota warnings
  5. Implement backoff - Use exponential backoff for retries

Anti-Patterns

❌ Direct API calls - Always use coordinator script

❌ Hardcoded delays - Use automatic rate limiting

❌ No retry logic - Implement exponential backoff

❌ Per-agent quotas - Use shared quota pool

❌ Ignoring rate limits - Always respect 429 responses

Configuration

Environment Variables

export GOOGLE_API_KEY="your-api-key"
export GOOGLE_SHEETS_QUOTA_LIMIT=300        # Requests per minute
export GOOGLE_SHEETS_QUOTA_WINDOW_MINUTES=1 # Quota window duration
export GOOGLE_API_TIMEOUT_SECONDS=10        # Request timeout

Quota File

Rate limit state stored in: .claude/cfn-extras/.gs-api-quota.json

{
  "quota_limit": 300,
  "window_start": "2025-11-18T10:00:00Z",
  "requests": [
    {"timestamp": "2025-11-18T10:00:15Z", "endpoint": "spreadsheets.values:get", "status": 200}
  ]
}

References

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.