Batch calculate CPF contributions
Calculate CPF contributions for multiple income scenarios (up to 100).
1 min read
post/calculate/batch
Request example
curl --request POST \
--url https://simplycpf.com/api/cpf/calculate/batch \
--header 'Content-Type: application/json' \
--data-raw '{
"scenarios": [
{
"income": 4000
},
{
"income": 6000
},
{
"income": 8000
}
]
}'import requests
url = "https://simplycpf.com/api/cpf/calculate/batch"
headers = {
"Content-Type": "application/json",
}
payload = {
"scenarios": [
{
"income": 4000
},
{
"income": 6000
},
{
"income": 8000
}
]
}
response = requests.request("POST", url, headers=headers, json=payload)
print(response.text)const response = await fetch('https://simplycpf.com/api/cpf/calculate/batch', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
"scenarios": [
{
"income": 4000
},
{
"income": 6000
},
{
"income": 8000
}
]
})
});
const data = await response.json();
console.log(data);<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://simplycpf.com/api/cpf/calculate/batch',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_POSTFIELDS => '{
"scenarios": [
{
"income": 4000
},
{
"income": 6000
},
{
"income": 8000
}
]
}',
CURLOPT_HTTPHEADER => [
'Content-Type: application/json',
],
]);
$response = curl_exec($curl);
curl_close($curl);
echo $response;package main
import (
"fmt"
"io"
"net/http"
"strings"
)
func main() {
url := "https://simplycpf.com/api/cpf/calculate/batch"
payload := strings.NewReader("{\n \"scenarios\": [\n {\n \"income\": 4000\n },\n {\n \"income\": 6000\n },\n {\n \"income\": 8000\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://simplycpf.com/api/cpf/calculate/batch"))
.header("Content-Type", "application/json")
.method("POST", HttpRequest.BodyPublishers.ofString("{\n \"scenarios\": [\n {\n \"income\": 4000\n },\n {\n \"income\": 6000\n },\n {\n \"income\": 8000\n }\n ]\n}"))
.build();
HttpResponse<String> response = HttpClient.newHttpClient()
.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());require 'uri'
require 'net/http'
url = URI('https://simplycpf.com/api/cpf/calculate/batch')
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = url.scheme == 'https'
request = Net::HTTP::Post.new(url)
request['Content-Type'] = 'application/json'
request.body = '{
"scenarios": [
{
"income": 4000
},
{
"income": 6000
},
{
"income": 8000
}
]
}'
response = http.request(request)
puts response.read_bodyResponse
[
{
"contribution": {
"totalContribution": 1,
"employer": 1,
"employee": 1
},
"distribution": {
"OA": 1,
"SA": 1,
"MA": 1
},
"afterCpfContribution": 1
}
]{
"error": "<string>"
}{
"error": "Rate limit exceeded"
}post/calculate/batch
Body
application/jsonResponses
application/json
Successful batch calculation
Take-home pay after CPF deduction
Error message
Error message