A fast REST API serving sustainability ratings for 500+ fashion brands
cargo run
# or for production:
cargo build --release
./target/release/rewoven-apiThe server starts on http://0.0.0.0:3000
GET /health
Returns API status, version, and total brand count
GET /api/brands?page=1&limit=50&category=Fast+Fashion&min_score=0&max_score=100&search=zara&sort=score_desc
Query Parameters:
page(default: 1) - Page numberlimit(default: 50, max: 100) - Items per pagecategory- Filter by category (e.g. "Fast Fashion", "Luxury", "Sustainable", "Sportswear", "Mid-Range", "Outdoor/Active", "Thrift/Resale")min_score/max_score- Filter by overall score range (0-100)search- Filter by brand name (substring match)sort- Sort order:score_desc,score_asc,name_asc,name_desc
Response:
{
"brands": [...],
"total": 505,
"page": 1,
"pages": 11
}GET /api/brands/:slug
Returns full brand details. Slug is the URL-friendly brand name (e.g. patagonia, h-and-m)
GET /api/brands/search?q=zara
Fuzzy search by brand name. Returns matches ranked by relevance (exact > starts with > contains > fuzzy)
GET /api/brands/top?limit=10
Returns the highest-rated brands sorted by overall score
GET /api/brands/worst?limit=10
Returns the lowest-rated brands sorted by overall score.
GET /api/brands/compare?brands=zara,patagonia,nike
Compare multiple brands side by side. Pass comma separated slugs
GET /api/categories
Lists all categories with average scores across all rating dimensions.
GET /api/stats
Overall statistics including total brands, average/median scores, grade distribution, category breakdown, and price range distribution.
| Field | Type | Description |
|---|---|---|
| name | string | Brand display name |
| slug | string | URL-friendly identifier |
| overall_score | 0-100 | Composite sustainability score |
| grade | A+ to F- | Letter grade based on overall score |
| environmental_score | 0-100 | Environmental impact rating |
| labor_score | 0-100 | Labor practices rating |
| transparency_score | 0-100 | Supply chain transparency rating |
| animal_welfare_score | 0-100 | Animal welfare rating |
| price_range | $ to $$$$ | Price tier |
| country | string | Headquarters country |
| category | string | Brand category |
| certifications | string[] | Sustainability certifications held |
| summary | string | Brief description of sustainability practices |
| website | string | Brand website URL |
- Build the release binary:
cargo build --release- Copy the binary to your VPS:
scp target/release/rewoven-api user@your-vps:/opt/rewoven-api/- Create a systemd service (
/etc/systemd/system/rewoven-api.service):
[Unit]
Description=Rewoven Brand Sustainability API
After=network.target
[Service]
Type=simple
ExecStart=/opt/rewoven-api/rewoven-api
Restart=always
RestartSec=5
Environment=RUST_LOG=info
[Install]
WantedBy=multi-user.target- Enable and start:
sudo systemctl enable rewoven-api
sudo systemctl start rewoven-api- Set up a reverse proxy with nginx or caddy to expose on port 80/443