Public
Server-side proxy for the Klipy GIF API (hides key, adds CORS)
Val Town is a collaborative website to build and scale JavaScript apps.
Deploy APIs, crons, & store data – all from the browser, and deployed in milliseconds.

klipy-proxy

A tiny server-side proxy for the Klipy GIF API. It keeps your Klipy API key off the client (stored as a Val Town env var) and adds permissive CORS so a browser frontend can call it directly.

Live base URL:

https://mashumaron-klipy-proxy.val.run

Endpoints

Method & pathKlipy call it makes
GET /api/klipy/trending?limit=30GET /gifs/trending (trending GIFs)
GET /api/klipy/search?q=cats&limit=30GET /gifs/search?q=… (GIF search)
GET /health check / endpoint list

The response is passed straight through from Klipy, so the JSON shape is:

{ "result": true, "data": { "data": [ { "id": 123, "title": "…", "file": { "sm": { "gif": { "url": "…" } }, "xs": {…}, "hd": {…} } } ] } }

Read GIF URLs from res.data.data[i].file.sm.gif.url (fall back to xs / hd).

Frontend usage

In script.js, point the proxy constant at this val:

var KLIPY_PROXY = 'https://mashumaron-klipy-proxy.val.run/api/klipy';

Everything else in loadKlipy() / renderGifs() stays the same.

Configuration

One secret env var is required:

KeyDescription
KLIPY_API_KEYYour Klipy API key (server-side only)

How it works

Rendering mermaid diagram...

Notes

  • Klipy requires a per-user customer_id; the proxy derives a stable anonymous one from the caller's IP so trending/search work without any frontend changes.
  • Responses are cached at the edge for 60s (cache-control) to spare the Klipy quota.
  • Only GIFs are proxied today. Stickers/clips would each need their own route (/stickers/*, /clips/*) — easy to add if you want them later.