2 min read
List products
Define a struct that matches the envelope, then decode into it:
package main
import (
"context"
"encoding/json"
"fmt"
"net/http"
"time"
)
type Product struct {
ID string `json:"id"`
Name string `json:"name"`
MaxAmount float64 `json:"max_amount"`
}
type ListResp struct {
Data []Product `json:"data"`
Error *struct {
Code string `json:"code"`
Message string `json:"message"`
} `json:"error"`
}
func main() {
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
defer cancel()
req, _ := http.NewRequestWithContext(ctx, "GET",
"https://api.credicorp.co.uk/public/v1/products", nil)
req.Header.Set("Accept", "application/json")
res, err := http.DefaultClient.Do(req)
if err != nil {
panic(err)
}
defer res.Body.Close()
var out ListResp
json.NewDecoder(res.Body).Decode(&out)
if out.Error != nil {
panic(fmt.Sprintf("%s: %s", out.Error.Code, out.Error.Message))
}
for _, p := range out.Data {
fmt.Printf("%s \u2014 up to \u00a3%.0f\n", p.Name, p.MaxAmount)
}
}
Reuse the client
Create one http.Client with a timeout at package scope and reuse it — never call http.Get in a loop, which leaks connections. The context deadline above cancels a slow request cleanly.
Frequently asked questions
Do I need a third-party HTTP library?
No. net/http covers every public-ring call. Add a router or client library only if your wider project already uses one.
How should I model money fields?
Amounts are returned as JSON numbers in whole pounds for these products. If you need exact decimal arithmetic, decode into a string or a decimal type rather than float64.
Related reading

Quickstart: your first Credicorp public API call with curl
The fastest way to see the Credicorp public API working is a single curl call to GET /public/v1/products. The…
Read →
Quickstart: call the Credicorp public API from Python
With the requests library you can call the Credicorp public API in about ten lines of Python. This quickstart…
Read →
Quickstart: call the Credicorp public API from Node.js
Node 18+ ships a global fetch, so you can call the Credicorp public API with zero dependencies. This…
Read →
Quickstart: get an indicative loan quote from the public API
POST /public/v1/quote turns an amount and term into an illustrative repayment. Send the requested amount and…
Read →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.