Integration Guides
PHP Integration
Using with Laravel
First, install the HTTP client:
composer require guzzlehttp/guzzle
Create a simple service class:
namespace App\Services;
use Illuminate\Support\Facades\Http;
class SheetsService
{
protected $apiKey;
protected $baseUrl = 'https://api.sheets.systems/v1';
public function __construct($apiKey)
{
$this->apiKey = $apiKey;
}
public function getSheetData($sheetId)
{
return Http::withHeaders([
'Authorization' => 'Bearer ' . $this->apiKey,
])->get("{$this->baseUrl}/sheets/{$sheetId}/data");
}
}
Usage Example
$sheets = new SheetsService($apiKey);
$response = $sheets->getSheetData('your-sheet-id');
if ($response->successful()) {
$data = $response->json();
// Process your data
}
JavaScript Integration
Using with Node.js
const axios = require('axios');
class SheetsAPI {
constructor(apiKey) {
this.apiKey = apiKey;
this.baseURL = 'https://api.sheets.systems/v1';
}
async getSheetData(sheetId) {
try {
const response = await axios.get(
`${this.baseURL}/sheets/${sheetId}/data`,
{
headers: {
'Authorization': `Bearer ${this.apiKey}`,
'Content-Type': 'application/json'
}
}
);
return response.data;
} catch (error) {
console.error('API Error:', error.response?.data);
throw error;
}
}
}
Python Integration
Using with Requests
import requests
class SheetsAPI:
def __init__(self, api_key):
self.api_key = api_key
self.base_url = 'https://api.sheets.systems/v1'
self.headers = {
'Authorization': f'Bearer {api_key}',
'Content-Type': 'application/json'
}
def get_sheet_data(self, sheet_id):
response = requests.get(
f'{self.base_url}/sheets/{sheet_id}/data',
headers=self.headers
)
response.raise_for_status()
return response.json()
CRUD Operations
Common operations examples for any language:
Create Row
// Adding a new row
await sheets.post(`/sheets/${sheetId}/data`, {
values: ['John Doe', 'john@example.com', '123-456-7890']
});
Read Data
// Reading with criteria
const response = await sheets.get(`/sheets/${sheetId}/rows/find`, {
params: {
criteria: {
email: 'john@example.com'
}
}
});
Update Row
// Updating matching rows
await sheets.put(`/sheets/${sheetId}/rows/update-by-criteria`, {
criteria: { email: 'john@example.com' },
updates: { phone: '555-0123' }
});
Authentication Best Practices
- Always store API keys securely (use environment variables)
- Use sheet-specific API keys when possible
- Rotate API keys periodically
- Monitor API usage through our dashboard
Environment Variables Example
# .env
SHEETS_API_KEY=your_api_key_here
SHEETS_ENDPOINT=https://api.sheets.systems/v1