Quickstart

Quickstart: use the Credicorp public API in Cloudflare Workers

Here is the idiomatic way to call the Credicorp public API from Cloudflare Workers. Fetch the product catalogue, cache it, and read the base host from configuration — the same shape you extend later for pricing and quotes, always keeping partner secrets server-side.

2 min read

Cloudflare WorkersIdiomatic integration
cacheCatalogue changes rarely
configBase URL from env

Call the API from Cloudflare Workers

export default {
  async fetch(request, env, ctx) {
    const cache = caches.default;
    let res = await cache.match(request);
    if (res) return res;
    res = await fetch('https://api.credicorp.co.uk/public/v1/products');
    res = new Response(res.body, res);
    res.headers.set('Cache-Control', 'public, max-age=3600');
    ctx.waitUntil(cache.put(request, res.clone()));
    return res;
  },
};

A Worker is an ideal cache-and-shape layer for the public catalogue: fetch once, cache at the edge with the Cache API, and serve product data to your front-end with near-zero latency. Store any partner secret in a Worker secret binding, never in the script.

Point at sandbox in development

Set the base URL to https://sandbox.credicorp.co.uk/public/v1 in development and CI, and to https://api.credicorp.co.uk/public/v1 in production — driven by the one environment variable your framework already exposes. See choosing a base URL.

Next steps

From here you can add a quote form, an enquiry submission or an embeddable product picker. Send applicants to apply to start a real journey.

Frequently asked questions

Can a Worker hold partner secrets?

Yes — use encrypted secret bindings (wrangler secret put). They are available to the Worker at runtime but never exposed to the browser, which makes edge functions a safe place for authenticated calls.

Should I cache the product list?

Yes. The catalogue changes infrequently, so cache it for the response's max-age. This keeps the API off your hot path and well under the rate limit.

Funding for UK limited companies

Credicorp lends to your company, not to you personally — short-term working capital with no personal guarantee. See what your business could access.