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

1

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.

Your full key is shown only once. Copy it immediately and store it in a secure location. If you lose it, regenerate a new one — this will invalidate the previous key.
2

Store your key safely

Add your API key to your project's environment variables. Never commit it to version control.

.env
# Add to your .env file
ASSETSREPO_API_KEY=ar_your_api_key_here
3

Test your connection

Verify everything works with a quick cURL request. Replace the path with any asset from your library.

Terminal
curl -H "Authorization: Bearer $ASSETSREPO_API_KEY" \
  https://assetsrepo.com/api/images/illustrations/hero.png

Never 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

PlanMonthly views
Pro 50K50,000
Pro 250K250,000
Pro 1M1,000,000
Pro 5M5,000,000

View counts reset on the 1st of each month. Monitor usage on your Account page.

Error Responses

StatusDescription
400Invalid storage key or API key sent as query parameter
401Missing, invalid, or deleted API key
403No active subscription or access denied
404Image not found at the specified path
429Monthly 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 .env to your .gitignore to 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