Your quickstart was configured for api.zerocarbon.codes (subdomain API), but your actual deployment uses:
- Production:
https://zerocarbon.codes/api/... - Local Dev:
http://localhost:3000/api/...
We've updated all quickstart files to work with your real deployment.
Before you start:
-
Your API must be deployed and working
- Production: https://zerocarbon.codes
- Test it: https://zerocarbon.codes/api/v1/emissions/calculate (should respond)
-
Required API endpoints must be public (no auth for testing):
/api/v1/emissions/calculate/api/v1/calculate/flight/api/v1/calculate/fuel
-
CORS must be configured for web demo to work
# From your project root
cd quickstart
node index.jsExpected Output:
βββββββββββββββββββββββββββββββββββββββββ
β ZeroCarbon API - Quick Start Demo β
βββββββββββββββββββββββββββββββββββββββββ
Welcome! This demo shows how easy it is to calculate carbon emissions.
No API key needed for testing.
π Demo 1: Electricity Emissions
Calculating emissions for 1,000 kWh of electricity in the US...
β
Result: 386.5 kg CO2e
π Scope: Scope 2 (Indirect emissions)
...
# Set environment variable to use localhost
$env:API_BASE="http://localhost:3000/api"
node index.jspython quickstart/quickstart.py# Start your Next.js dev server
npm run dev
# Then open in browser:
# http://localhost:3000/quickstart/web-demo.html# Production
.\quickstart\curl-examples.sh
# Or with custom API
$env:API_BASE="http://localhost:3000/api"
.\quickstart\curl-examples.shYour API endpoints need to allow unauthenticated requests for the quickstart to work.
Create src/middleware/publicTesting.ts:
import { NextRequest, NextResponse } from 'next/server';
// IP-based rate limiting (simple in-memory store)
const rateLimitMap = new Map<string, { count: number; resetTime: number }>();
export function publicTestingMiddleware(request: NextRequest) {
const pathname = request.nextUrl.pathname;
// Allow public access to these endpoints
const publicEndpoints = [
'/api/v1/emissions/calculate',
'/api/v1/calculate/flight',
'/api/v1/calculate/fuel',
];
const isPublicEndpoint = publicEndpoints.some(endpoint =>
pathname.startsWith(endpoint)
);
if (!isPublicEndpoint) {
return null; // Not a public endpoint, continue to auth
}
// Rate limiting: 1000 requests per day per IP
const ip = request.ip || request.headers.get('x-forwarded-for') || 'unknown';
const now = Date.now();
const dayInMs = 24 * 60 * 60 * 1000;
let rateLimit = rateLimitMap.get(ip);
if (!rateLimit || now > rateLimit.resetTime) {
rateLimit = { count: 0, resetTime: now + dayInMs };
rateLimitMap.set(ip, rateLimit);
}
rateLimit.count++;
if (rateLimit.count > 1000) {
return NextResponse.json({
error: 'Rate limit exceeded',
message: 'You have exceeded the testing limit. Get a free API key at https://zerocarbon.codes/signup'
}, { status: 429 });
}
// Add CORS headers for web demo
const response = NextResponse.next();
response.headers.set('Access-Control-Allow-Origin', '*');
response.headers.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
response.headers.set('Access-Control-Allow-Headers', 'Content-Type');
return response;
}Add to your middleware.ts:
import { NextResponse } from 'next/server';
import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
const pathname = request.nextUrl.pathname;
// Public testing endpoints (no auth required)
const publicTestingEndpoints = [
'/api/v1/emissions/calculate',
'/api/v1/calculate/flight',
'/api/v1/calculate/fuel',
];
// Allow CORS for public endpoints
if (publicTestingEndpoints.some(endpoint => pathname.startsWith(endpoint))) {
// Handle OPTIONS request
if (request.method === 'OPTIONS') {
return new NextResponse(null, {
status: 200,
headers: {
'Access-Control-Allow-Origin': '*',
'Access-Control-Allow-Methods': 'GET, POST, OPTIONS',
'Access-Control-Allow-Headers': 'Content-Type, Authorization',
},
});
}
// Add CORS headers to response
const response = NextResponse.next();
response.headers.set('Access-Control-Allow-Origin', '*');
response.headers.set('Access-Control-Allow-Methods', 'GET, POST, OPTIONS');
response.headers.set('Access-Control-Allow-Headers', 'Content-Type, Authorization');
return response;
}
// ... rest of your auth middleware
}
export const config = {
matcher: [
'/api/:path*',
// ... other routes
],
};# Copy web-demo.html to your public folder
cp quickstart/web-demo.html public/quickstart-demo.html
# Access at: https://zerocarbon.codes/quickstart-demo.htmlcd quickstart
# Create vercel.json
@"
{
"rewrites": [
{ "source": "/", "destination": "/web-demo.html" }
]
}
"@ | Out-File -Encoding utf8 vercel.json
# Deploy
npx vercel --prod
# Set custom domain (optional)
# vercel domains add quickstart.zerocarbon.codescd quickstart
# Install Netlify CLI
npm install -g netlify-cli
# Deploy
netlify deploy --prod --dir=.
# Set site name: zerocarbon-quickstartcd quickstart
# 1. Login to NPM
npm login
# Enter your npm username, password, and email
# 2. Update package.json name if needed
# If "zerocarbon-quickstart" is taken, use:
# @zerocarbon/quickstart
# or @yourusername/zerocarbon-quickstart
# 3. Publish
npm publish --access public
# 4. Test installation
npx zerocarbon-quickstart
# (or your chosen package name)Package.json should look like:
{
"name": "zerocarbon-quickstart",
"version": "1.0.0",
"description": "Interactive quickstart for ZeroCarbon API",
"main": "index.js",
"bin": {
"zerocarbon-quickstart": "./index.js"
},
"keywords": ["carbon", "emissions", "climate", "api", "quickstart"],
"author": "ZeroCarbon",
"license": "MIT",
"repository": {
"type": "git",
"url": "https://github.com/zerocarbon/quickstart"
}
}-
Create GitHub repo:
cd quickstart git init git add . git commit -m "Initial commit: ZeroCarbon API Quickstart" # Create repo on GitHub, then: git remote add origin https://github.com/yourusername/zerocarbon-quickstart.git git branch -M main git push -u origin main
-
Import to Replit:
- Go to https://replit.com
- Click "Create Repl"
- Select "Import from GitHub"
- Enter your repo URL:
yourusername/zerocarbon-quickstart - Click "Import"
-
Configure Repl:
- Run command:
node index.js - Make repl public (Share β Public)
- Get link:
https://replit.com/@yourusername/zerocarbon-quickstart
- Run command:
- Create new Repl on Replit.com
- Select "Node.js" template
- Upload all quickstart files
- Set run command to
node index.js - Make public and get shareable link
- Go to https://codesandbox.io
- Click "Create Sandbox"
- Select "Import from GitHub"
- Enter:
yourusername/zerocarbon-quickstart - Make sandbox public
- Get link:
https://codesandbox.io/s/github/yourusername/zerocarbon-quickstart
- Create new Node.js sandbox
- Upload files from quickstart/ directory
- Make public
- Get shareable link
Update quickstart/README.md with your actual links:
# ZeroCarbon API - 5-Minute Quickstart
## Try It Now
**Option 1: NPM (30 seconds)**
```bash
npx zerocarbon-quickstartOption 2: Web Demo (10 seconds) π Open Interactive Demo π
---
## π§ͺ Step 8: End-to-End Testing
### Test Checklist
```powershell
# 1. Test local Node.js demo
node quickstart/index.js
# 2. Test with production API
$env:API_BASE="https://zerocarbon.codes/api"
node quickstart/index.js
# 3. Test Python demo
python quickstart/quickstart.py
# 4. Test cURL examples
.\quickstart\curl-examples.sh
# 5. Test web demo
# Open: http://localhost:3000/quickstart-demo.html
# (or your deployed URL)
# 6. Test NPM package
npx zerocarbon-quickstart
# 7. Test from different computer/network
# Use online tools: replit.com, codesandbox.io
# 8. Test rate limiting
# Make >1000 requests and verify 429 error
- All API endpoints return valid JSON
- No CORS errors in browser console
- Response times < 1 second
- Error messages are helpful (not stack traces)
- Rate limiting works (429 after 1000 requests)
- Works on Windows, Mac, Linux
- Works in Chrome, Firefox, Safari
- NPM package installs and runs globally
- Replit demo works without configuration
- CodeSandbox demo works without setup
In "How do you know people want your product?":
We're the fastest carbon API to integrate. Try it yourself RIGHT NOW:
1. Run in terminal: npx zerocarbon-quickstart
2. Or open: https://zerocarbon.codes/quickstart-demo.html
3. Or fork: https://replit.com/@yourusername/zerocarbon-quickstart
You'll get a real carbon calculation in under 60 seconds.
Our beta users integrate in 18 minutes average (vs. 2-3 hours for competitors).
The secret? Zero frictionβno signup, no API key, no sales call. Just code.
In "Product Demo URL":
https://zerocarbon.codes/quickstart-demo.html
Have this ready to screen share:
- Open terminal
- Run:
npx zerocarbon-quickstart - Show real-time results
- Say: "This is what every developer experiences. Zero friction. This is our moat."
Cause: Old hardcoded URL Fix:
# Set correct API base
$env:API_BASE="https://zerocarbon.codes/api"
node quickstart/index.jsCause: Missing CORS headers Fix: Add to your API middleware:
response.headers.set('Access-Control-Allow-Origin', '*');Cause: Endpoint requires authentication Fix: Update middleware to allow public access (see Step 2)
Cause: Endpoint doesn't exist Fix: Check your API routes exist:
/api/v1/emissions/calculate/api/v1/calculate/flight/api/v1/calculate/fuel
Cause: Database query performance Fix:
- Add database indexes
- Cache common calculations
- Use Vercel Edge Functions
Cause: Package name already taken Fix: Use scoped package:
{
"name": "@zerocarbon/quickstart"
}Track these metrics:
// Add to your API routes
import { analytics } from '@/lib/analytics';
export async function POST(request: Request) {
// ... your endpoint logic
// Track quickstart usage
await analytics.track('quickstart_api_call', {
endpoint: '/v1/emissions/calculate',
source: request.headers.get('referer'),
userAgent: request.headers.get('user-agent'),
});
}Monitor:
- Daily API calls from quickstart
- Conversion: quickstart β signup β paid
- Geographic distribution
- Most popular endpoints
- Error rates
Track on your admin dashboard:
- Quickstart demos run today: X
- NPM downloads this week: Y
- Replit forks: Z
- Conversion rate: A%
Before announcing your quickstart:
Technical:
- All demos tested on 3 different machines
- API endpoints working in production
- CORS configured correctly
- Rate limiting tested
- Error messages are helpful
- Response times < 1 second
Distribution:
- NPM package published
- Web demo deployed
- Replit demo public
- CodeSandbox demo public
- GitHub repo created and public
Documentation:
- README updated with actual links
- YC application updated
- API docs mention quickstart
- Homepage has "Try Demo" button
Marketing:
- Tweet prepared about quickstart
- Reddit post drafted (r/programming)
- Email to beta users
- YC application submitted
- Test everything (Step 8 checklist)
- Deploy web demo (Step 3)
- Publish NPM package (Step 4)
- Create Replit/CodeSandbox (Steps 5-6)
- Update YC application (Step 9)
- Announce on Twitter
- Monitor usage (Step 10)
-
Make it bulletproof:
- Demos should NEVER fail
- Have fallback mock data
- Show helpful error messages
-
Track everything:
- Log every demo run
- Know exactly what YC partners see
- Fix issues within 1 hour
-
Optimize for speed:
- Cache common calculations
- Use CDN for web demo
- Aim for <200ms API responses
-
Be available:
- Monitor email during YC review
- Fix issues immediately
- Have phone ready for urgent bugs
If you need help:
- Test locally first:
node quickstart/index.js - Check API is running: Visit https://zerocarbon.codes/api/v1/emissions/calculate
- Verify CORS: Check browser console for errors
- Check rate limits: Make sure you haven't hit 1000 requests
- Review logs: Check Vercel deployment logs
Ready to launch? Start with Step 1! π