Quickstart

Quickstart: call the Credicorp public API from Java

Here is the idiomatic Java way to make your first Credicorp public API call. List the live products from GET /public/v1/products, set a timeout, and turn the documented error envelope into an error you can handle — the pattern every other public-ring call reuses.

2 min read

JavaFirst call
timeoutBound every request
data[]Unwrap the envelope

List products

import java.net.http.*;
import java.net.URI;

var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder()
    .uri(URI.create("https://api.credicorp.co.uk/public/v1/products"))
    .header("Accept", "application/json")
    .timeout(java.time.Duration.ofSeconds(10))
    .build();
var res = client.send(req, HttpResponse.BodyHandlers.ofString());
if (res.statusCode() >= 400) throw new RuntimeException(res.body());
System.out.println(res.body());

Java 11+ ships java.net.http.HttpClient, so you can call the API with no third-party HTTP library. Decode the JSON with Jackson or Gson, and set a request timeout as shown.

Use the sandbox in development

Point the base host at https://sandbox.credicorp.co.uk/public/v1 in development and CI, and at https://api.credicorp.co.uk/public/v1 in production, driven by one environment variable. See choosing a base URL.

Next steps

From here, request a quote, submit an enquiry, and send applicants to apply. Handle errors with the shared error envelope.

Frequently asked questions

Do I need OkHttp or Apache HttpClient?

No. The built-in HttpClient (Java 11+) covers every public-ring call. Add a third-party client only if your project already standardises on one.

How do I handle errors in Java?

Check the status code and read the error object from the body — error.code is the stable machine string to branch on. The pattern is identical across every endpoint.

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.