# Webby Basic Usage Examples
## Quick Start
### 1. Test Performance (PageSpeed Insights - Fast)
```typescript
validate_performance_pagespeed("https://example.com")
```
**Returns in ~3 seconds:**
```json
{
"tool": "pagespeed",
"success": true,
"url": "https://example.com",
"strategy": "mobile",
"performance_score": 92,
"accessibility_score": 95,
"best_practices_score": 88,
"seo_score": 90,
"metrics": {
"firstContentfulPaint": 1200,
"largestContentfulPaint": 2100,
"totalBlockingTime": 150,
"cumulativeLayoutShift": 0.05,
"speedIndex": 2300,
"timeToInteractive": 3500
},
"crux_data": true
}
```
### 2. Test Performance (WebPageTest - Comprehensive)
**Quick mode (instant response):**
```typescript
validate_performance_webpagetest("https://example.com")
```
**Returns immediately:**
```json
{
"tool": "webpagetest",
"success": true,
"url": "https://example.com",
"test_id": "250107_AiDcA4_ABC",
"results_url": "https://www.webpagetest.org/result/250107_AiDcA4_ABC/",
"status": "pending"
}
```
**Complete mode (wait for results):**
```typescript
validate_performance_webpagetest("https://example.com", {
waitForResults: true,
timeout: 300000 // 5 minutes
})
```
**Returns after 2-5 minutes:**
```json
{
"tool": "webpagetest",
"success": true,
"url": "https://example.com",
"test_id": "250107_AiDcA4_ABC",
"results_url": "https://www.webpagetest.org/result/250107_AiDcA4_ABC/",
"status": "complete",
"summary": {
"loadTime": 2500,
"firstContentfulPaint": 1200,
"speedIndex": 2300,
"largestContentfulPaint": 2100,
"timeToInteractive": 3500,
"totalBlockingTime": 250,
"cumulativeLayoutShift": 0.05
},
"performance_grade": "A",
"security_grade": "A+"
}
```
### 3. Test Accessibility (Free)
```typescript
validate_accessibility_axe("https://example.com")
```
**Returns:**
```json
{
"tool": "axe",
"success": true,
"url": "https://example.com",
"wcagLevel": "wcag2aa",
"violations": 3,
"critical": 0,
"serious": 2,
"moderate": 1,
"minor": 0,
"passes": 47,
"incomplete": 2,
"issues": [
{
"id": "color-contrast",
"impact": "serious",
"description": "Elements must have sufficient color contrast",
"helpUrl": "https://dequeuniversity.com/rules/axe/4.10/color-contrast",
"nodes": 3
}
]
}
```
### 4. Test Security
```typescript
validate_all_security("https://example.com", {
email: "your@email.com",
waitForSSL: false // Get Mozilla results immediately, SSL Labs pending
})
```
**Returns:**
```json
{
"url": "https://example.com",
"timestamp": "2025-01-07T20:00:00Z",
"mozilla_observatory": {
"tool": "mozilla_observatory",
"success": true,
"grade": "A",
"score": 95,
"tests_passed": 9,
"tests_failed": 1,
"scanned_at": "2025-01-07T20:00:00Z",
"details_url": "https://developer.mozilla.org/en-US/observatory/analyze?host=example.com"
},
"ssl_labs": {
"tool": "ssl_labs",
"success": true,
"status": "IN_PROGRESS",
"host": "example.com",
"endpoints": [
{
"ip": "93.184.216.34",
"progress": 50
}
]
},
"summary": {
"mozilla_grade": "A",
"ssl_grade": null,
"overall_success": true
}
}
```
### 5. Run All Performance Tests
```typescript
validate_all_performance("https://example.com", {
webpagetestEnabled: true,
webpagetestWaitForResults: false
})
```
**Returns:**
```json
{
"url": "https://example.com",
"timestamp": "2025-01-07T20:00:00Z",
"pagespeed": { /* PageSpeed results */ },
"webpagetest": { /* WebPageTest results */ },
"summary": {
"tools_run": ["pagespeed", "webpagetest"],
"avg_performance_score": 88.5
}
}
```
### 6. Comprehensive Validation
```typescript
validate_comprehensive("https://example.com", {
email: "your@email.com",
categories: ["performance", "accessibility", "security"],
webpagetestEnabled: true
})
```
**Returns:**
```json
{
"url": "https://example.com",
"timestamp": "2025-01-07T20:00:00Z",
"performance": { /* All performance results */ },
"accessibility": { /* All accessibility results */ },
"security": { /* All security results */ },
"summary": {
"categories_tested": ["performance", "accessibility", "security"],
"overall_health": "good",
"critical_issues": 2
}
}
```
## Common Patterns
### Cross-Validation (Compare Multiple Tools)
```typescript
// Get PageSpeed and WebPageTest results
validate_all_performance("https://example.com", {
webpagetestEnabled: true,
webpagetestWaitForResults: true
})
// Compare scores:
// PageSpeed: 92
// WebPageTest: 85
// Consensus: ~88.5 average
```
### Progressive Enhancement
```typescript
// 1. Quick check with PageSpeed
validate_performance_pagespeed("https://example.com")
// 2. If issues found, deep dive with WebPageTest
validate_performance_webpagetest("https://example.com", {
waitForResults: true,
location: "London:Chrome",
runs: 3 // Run 3 times for consistency
})
```
### Accessibility First
```typescript
// Always run Axe first (free, fast)
validate_accessibility_axe("https://example.com")
// If critical issues found and budget allows, verify with WAVE
validate_accessibility_wave("https://example.com", {
apiKey: "your-wave-api-key"
})
```
## API Keys & Quotas
### Free (No API Key)
- **PageSpeed Insights**: 25,000 requests/day (no key), unlimited with free key
- **WebPageTest**: 300 tests/month (browser automation)
- **Axe**: Unlimited (browser automation)
- **Mozilla Observatory**: 1 scan/min per domain
- **SSL Labs**: Unlimited (rate limited, requires email)
### Paid (API Key Required)
- **GTmetrix**: Free tier with API key, paid tiers for more credits
- **WAVE**: Subscription required
## Tips
1. **Start with free tools** - PageSpeed + Axe + Mozilla Observatory cover 80% of needs
2. **Use WebPageTest sparingly** - Only 300/month, save for detailed analysis
3. **Enable waitForResults carefully** - WebPageTest and SSL Labs can take 2-5 minutes
4. **Cross-validate** - Different tools use different methodologies, compare results
5. **Cache results** - Don't re-test the same URL repeatedly, save your quotas