Ejemplos de código

Código listo para copiar y usar en tu proyecto.

Python

Consulta simple

python
import requests
API_KEY = "ps_live_TU_API_KEY"
BASE = "https://argenapi.com/api/v1"
response = requests.get(
f"{BASE}/lookup",
params={"identifier": "0070026930004037264164", "type": "cbu"},
headers={"Authorization": f"Bearer {API_KEY}"}
)
data = response.json()
if data.get("success"):
for holder in data["data"]["holders"]:
print(f"Titular: {holder['full_name']} ({holder['tax_id']})")
print(f"Banco: {data['data']['bank']['name']}")
print(f"Créditos restantes: {data['credits_remaining']}")
else:
print(f"Error: {data.get('error_message')}")

Consulta con manejo de errores

python
import requests
import time
API_KEY = "ps_live_TU_API_KEY"
BASE = "https://argenapi.com/api/v1"
def lookup_cbu(identifier: str, id_type: str = "cbu") -> dict | None:
try:
response = requests.get(
f"{BASE}/lookup",
params={"identifier": identifier, "type": id_type},
headers={"Authorization": f"Bearer {API_KEY}"},
timeout=15
)
if response.status_code == 429:
reset = int(response.headers.get("X-RateLimit-Reset", time.time() + 60))
wait = max(reset - int(time.time()), 1)
print(f"Rate limited. Esperando {wait}s...")
time.sleep(wait)
return lookup_cbu(identifier, id_type)
data = response.json()
if not data.get("success"):
print(f"Error {data.get('error_code')}: {data.get('error_message')}")
return None
return data["data"]
except requests.RequestException as e:
print(f"Error de conexión: {e}")
return None
# Uso
result = lookup_cbu("0070026930004037264164")
if result:
print(result["holders"][0]["full_name"])

Consulta masiva con rate limiting

python
import requests
import time
API_KEY = "ps_live_TU_API_KEY"
BASE = "https://argenapi.com/api/v1"
cbus = [
"0070026930004037264164",
"2850590940090418135201",
"0140000001600000000015",
]
results = []
for i, cbu in enumerate(cbus):
response = requests.get(
f"{BASE}/lookup",
params={"identifier": cbu, "type": "cbu"},
headers={"Authorization": f"Bearer {API_KEY}"}
)
if response.status_code == 429:
reset = int(response.headers.get("X-RateLimit-Reset", time.time() + 60))
time.sleep(max(reset - int(time.time()), 1))
continue
data = response.json()
results.append({"cbu": cbu, "result": data})
print(f"[{i+1}/{len(cbus)}] {cbu}: {'OK' if data.get('success') else data.get('error_code')}")
# Respetar rate limit: ~1 req/seg
time.sleep(1)

Node.js

Con fetch

node.js
const API_KEY = "ps_live_TU_API_KEY";
const BASE = "https://argenapi.com/api/v1";
async function lookupCBU(identifier, type = "cbu") {
const url = new URL(`${BASE}/lookup`);
url.searchParams.set("identifier", identifier);
url.searchParams.set("type", type);
const res = await fetch(url, {
headers: { "Authorization": `Bearer ${API_KEY}` }
});
const data = await res.json();
if (!data.success) {
console.error(`Error ${data.error_code}: ${data.error_message}`);
return null;
}
return data.data;
}
// Uso
const result = await lookupCBU("0070026930004037264164");
if (result) {
console.log("Titular:", result.holders[0].full_name);
console.log("Banco:", result.bank.name);
}

Con manejo de errores

node.js
async function lookupSafe(identifier, type = "cbu") {
try {
const res = await fetch(
`https://argenapi.com/api/v1/lookup?identifier=${encodeURIComponent(identifier)}&type=${type}`,
{
headers: { "Authorization": "Bearer ps_live_TU_API_KEY" },
signal: AbortSignal.timeout(15000)
}
);
if (res.status === 429) {
const reset = res.headers.get("X-RateLimit-Reset");
const wait = reset ? Math.max(Number(reset) - Math.floor(Date.now() / 1000), 1) : 60;
console.log(`Rate limited. Reintentando en ${wait}s...`);
await new Promise(r => setTimeout(r, wait * 1000));
return lookupSafe(identifier, type);
}
return await res.json();
} catch (err) {
console.error("Error:", err.message);
return { success: false, error_message: err.message };
}
}

PHP

php
<?php
$api_key = "ps_live_TU_API_KEY";
$base_url = "https://argenapi.com/api/v1";
function lookupCBU(string $identifier, string $type = "cbu"): ?array {
global $api_key, $base_url;
$url = $base_url . "/lookup?" . http_build_query([
"identifier" => $identifier,
"type" => $type,
]);
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_HTTPHEADER, ["Authorization: Bearer $api_key"]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 15);
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
$data = json_decode($response, true);
if ($httpCode === 429) {
echo "Rate limited. Esperando...\n";
sleep(60);
return lookupCBU($identifier, $type);
}
if (!($data["success"] ?? false)) {
echo "Error: " . ($data["error_message"] ?? "desconocido") . "\n";
return null;
}
return $data["data"];
}
// Uso
$result = lookupCBU("0070026930004037264164");
if ($result) {
echo "Titular: " . $result["holders"][0]["full_name"] . "\n";
echo "Banco: " . $result["bank"]["name"] . "\n";
}
?>

Google Sheets (Apps Script)

Función personalizada para usar directamente en celdas de Google Sheets. Ingresá =CONSULTAR_CBU("0070...") en cualquier celda.

Apps Script
const API_KEY = "ps_live_TU_API_KEY";
const BASE = "https://argenapi.com/api/v1";
/**
* Consulta el titular de un CBU o Alias.
* @param {string} identifier CBU (22 dígitos) o Alias
* @param {string} type "cbu" o "alias" (default: "cbu")
* @return {string} Nombre del titular
* @customfunction
*/
function CONSULTAR_CBU(identifier, type) {
type = type || "cbu";
var url = BASE + "/lookup?identifier=" + encodeURIComponent(identifier) + "&type=" + type;
var options = {
method: "get",
headers: { "Authorization": "Bearer " + API_KEY },
muteHttpExceptions: true
};
var response = UrlFetchApp.fetch(url, options);
var data = JSON.parse(response.getContentText());
if (!data.success) {
return "Error: " + (data.error_message || data.error_code);
}
return data.data.holders.map(function(o) { return o.full_name; }).join(", ");
}