API Documentation
Serve optimized images from AssetsRepo directly in your websites and applications using a simple REST API.
Base URL
https://assetsrepo.com/api/images/{path}Getting Started
Prerequisites
- An active Pro subscription (monthly or yearly) on any tier
- An API key generated from your account settings
Generate your API key
Navigate to your Account page and scroll to the API Key section. Click Generate API Key to create a new key.
Store your key safely
Add your API key to your project's environment variables. Never commit it to version control.
# Add to your .env file
ASSETSREPO_API_KEY=ar_your_api_key_hereTest your connection
Verify everything works with a quick cURL request. Replace the path with any asset from your library.
curl -H "Authorization: Bearer $ASSETSREPO_API_KEY" \
https://assetsrepo.com/api/images/illustrations/hero.pngNever expose your API key in client-side code
Do not pass your key as a URL query parameter or include it in frontend source. Always proxy requests through your backend where the key stays private.
Server-Side Proxy
Create a backend endpoint that fetches images from AssetsRepo and serves them to your frontend. Your users never see the API key.
export async function GET(
request: Request,
{ params }: { params: Promise<{ path: string[] }> }
) {
const { path } = await params;
const storageKey = path.join("/");
const response = await fetch(
`https://assetsrepo.com/api/images/${storageKey}`,
{
headers: {
Authorization: `Bearer ${process.env.ASSETSREPO_API_KEY}`,
},
}
);
if (!response.ok) {
return new Response("Not found", { status: response.status });
}
return new Response(response.body, {
headers: {
"Content-Type": response.headers.get("Content-Type") || "image/png",
"Cache-Control": "public, max-age=31536000, immutable",
},
});
}All examples set a Cache-Control header with a one-year max-age. This means browsers and CDNs cache images aggressively, reducing API calls and keeping you well within your view limit.
Frontend Usage
Once your proxy is running, reference images using your own endpoint. The API key never leaves your server.
<!-- Points to YOUR server, which proxies to AssetsRepo -->
<img
src="/assets/illustrations/hero-banner.png"
alt="Hero banner"
loading="lazy"
/>API Reference
Rate Limits
| Plan | Monthly views |
|---|---|
| Pro 50K | 50,000 |
| Pro 250K | 250,000 |
| Pro 1M | 1,000,000 |
| Pro 5M | 5,000,000 |
View counts reset on the 1st of each month. Monitor usage on your Account page.
Error Responses
| Status | Description |
|---|---|
400 | Invalid storage key or API key sent as query parameter |
401 | Missing, invalid, or deleted API key |
403 | No active subscription or access denied |
404 | Image not found at the specified path |
429 | Monthly view limit exceeded |
Security Best Practices
- Store your API key in environment variables — never hardcode it in source files
- Always proxy requests through your backend — the key should never reach the browser
- Add
.envto your.gitignoreto prevent accidental commits - Regenerate your key immediately if you suspect it has been compromised
- Set long-lived cache headers on your proxy to minimize API calls and stay within your view limit
Need a Pro subscription to get started?
View pricing