Quickstart
This guide will help you get started with the banca.me API integration. Follow these steps to make your first API request.
Prerequisites​
Before you begin, make sure you have:
- A banca.me account
- Your API credentials (Bearer token)
- A development environment set up
Making Your First Request​
You can now make requests to various endpoints. Here's an example of creating a pre-loan request:
- Python
- JavaScript
- PHP
- Java
- cURL
import requests
from urllib.parse import urlencode
# Set up your authentication headers
headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/x-www-form-urlencoded'
}
# Create a pre-loan request
payload = {
'rut': '<RUT>',
'metadata': {}
}
# Encode the payload for x-www-form-urlencoded format
payload_encoded = urlencode(payload)
# Make the POST request
response = requests.post(
'https://api.banca.me/partner/pre-loan-request',
data=payload_encoded,
headers=headers
)
# Handle the response
if response.status_code == 200:
print("Success:", response.json())
else:
print("Error:", response.status_code, response.text)
const axios = require('axios');
// Set up your authentication headers
const headers = {
'Authorization': 'Bearer <token>',
'Content-Type': 'application/x-www-form-urlencoded'
};
// Create a pre-loan request
const payload = {
rut: '<RUT>',
metadata: {}
};
// Convert payload to x-www-form-urlencoded format
const payload_encoded = new URLSearchParams(payload).toString();
// Make the POST request
try {
const response = await axios.post(
'https://api.banca.me/partner/pre-loan-request',
payload_encoded,
{ headers }
);
console.log('Success:', response.data);
} catch (error) {
console.error('Error:', error.response?.status, error.response?.data);
}
<?php
// Set up your authentication headers
$headers = array(
'Authorization: Bearer <token>',
'Content-Type: application/x-www-form-urlencoded'
);
// Create a pre-loan request
$payload = array(
'rut' => '<RUT>',
'metadata' => '{}'
);
// Initialize cURL session
$ch = curl_init('https://api.banca.me/partner/pre-loan-request');
// Set cURL options
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($payload));
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// Execute the request
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
// Handle the response
if ($httpCode === 200) {
$data = json_decode($response, true);
echo "Success: " . print_r($data, true);
} else {
echo "Error: " . $httpCode . " - " . $response;
}
// Close cURL session
curl_close($ch);
?>
import java.io.BufferedReader;
import java.io.DataOutputStream;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
import java.util.Map;
import java.util.StringJoiner;
public class BancameApiExample {
public static void main(String[] args) {
try {
// Set up your authentication headers
String token = "<token>";
// Create a pre-loan request
Map<String, String> payload = new HashMap<>();
payload.put("rut", "<RUT>");
payload.put("metadata", "{}");
// Convert payload to x-www-form-urlencoded format
StringJoiner sj = new StringJoiner("&");
for (Map.Entry<String, String> entry : payload.entrySet()) {
sj.add(URLEncoder.encode(entry.getKey(), "UTF-8") + "="
+ URLEncoder.encode(entry.getValue(), "UTF-8"));
}
String payloadEncoded = sj.toString();
// Create connection
URL url = new URL("https://api.banca.me/partner/pre-loan-request");
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Authorization", "Bearer " + token);
conn.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
conn.setDoOutput(true);
// Send request
try (DataOutputStream wr = new DataOutputStream(conn.getOutputStream())) {
wr.write(payloadEncoded.getBytes(StandardCharsets.UTF_8));
}
// Handle response
int responseCode = conn.getResponseCode();
BufferedReader in = new BufferedReader(
new InputStreamReader(
responseCode == 200 ? conn.getInputStream() : conn.getErrorStream()
)
);
StringBuilder response = new StringBuilder();
String line;
while ((line = in.readLine()) != null) {
response.append(line);
}
in.close();
if (responseCode == 200) {
System.out.println("Success: " + response.toString());
} else {
System.out.println("Error: " + responseCode + " - " + response.toString());
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
# Set up your authentication headers
TOKEN="<token>"
# Make a pre-loan request
curl -X POST 'https://api.banca.me/partner/pre-loan-request' \
-H "Authorization: Bearer $TOKEN" \
-H 'Content-Type: application/x-www-form-urlencoded' \
-d 'rut=<RUT>&metadata={}'
Never expose your Bearer token in client-side code. Always make API requests from your backend server.
Response Handling​
The API will return different responses based on the status of the pre-loan request. Please check our API documentation for more detail. Here are the possible responses:
- Product Ready (200)
- Product Success (200)
- Product Failed (200)
- Being Evaluated (200)
- Needs Information (201)
For this section please check the data format response from the data section. When the product is ready for evaluation, you'll receive detailed information about the customer's financial status:
{
"step": "READY_FOR_LOAN",
"protestsAndDelinquencies": {
// See Protests And Delinquencies section in Data
},
"claveUnica": {
// See ClaveÚnica: AFC, SII, SUSESO and CMF section in Data
},
"preApproves": [
// See Risk Params and PreApproves section
]
}
When the loan is successfully processed and active:
{
"step": "ARCHIVED_SUCCESS",
"product": {
"loanAmount": 660000,
"interestRate": 0.29,
"periods": 2,
"installmentAmount": 330000,
"lastInstallmentAmount": 330000,
"state": "ACTIVE",
"transferDate": "2022-08-01",
"installments": [
{
"state": "ACTIVE",
"period": 1,
"expirationDate": "2022-09-01"
},
{
"state": "ACTIVE",
"period": 2,
"expirationDate": "2022-10-01"
}
]
}
}
When the loan request is rejected:
{
"step": "ARCHIVED_FAILED",
"archivedComment": "El lead fue rechazado por ESTE motivo."
}
When the loan request is under evaluation:
{
"step": "ARCHIVED_FAILED",
"archivedComment": "El lead fue rechazado por ESTE motivo."
}
When additional user information is required:
{
"url": "http://www.creditos.banca.me/preloan?token=eyJhbG...",
"step": "NEEDS_CU"
}
Always check the step field in the response to determine the current state of the loan request and handle each case appropriately in your application.
Error Handling​
Always implement proper error handling in your code:
- Check HTTP status codes
- Parse error messages from the response
- Implement retry logic for temporary failures
- Log errors for debugging
Next Steps​
- Explore the API Reference for all available endpoints