Documentacion de la API
Introduccion
La API de Extraer Datos de INE te permite extraer datos de credenciales de elector mexicanas (INE/IFE) de manera programatica. Utiliza inteligencia artificial para procesar las imagenes y extraer todos los campos visibles de la credencial.
URL Base: https://extraerdatosdeine.com//api/v1
Autenticacion
Todas las peticiones a la API requieren autenticacion mediante una API key. Incluye tu API key en el header X-API-Key de cada peticion.
curl -H "X-API-Key: ine_tu_api_key" \ https://extraerdatosdeine.com//api/v1/balance
Puedes generar y administrar tus API keys desde el dashboard.
Metodos de Upload
La API soporta multiples metodos para enviar imagenes. El metodo se detecta automaticamente del header Content-Type.
| Metodo | Content-Type | Uso recomendado |
|---|---|---|
| Recomendado Multipart | multipart/form-data | curl, Postman, formularios HTML |
| Base64 JSON | application/json | JavaScript, apps moviles |
| URL Fetch | application/json | Imagenes hospedadas en la nube |
| Binario | image/jpeg, image/png, image/webp | CLI tools, streaming |
Endpoints
/api/v1/extractExtrae datos de una imagen de credencial INE/IFE.
RecomendadoMultipart Form-Data
Envia archivos directamente. Ideal para curl y Postman.
| Campo | Tipo | Descripcion |
|---|---|---|
image_front | file | Imagen frontal (requerido) |
image_back | file | Imagen trasera (opcional) |
curl -X POST https://extraerdatosdeine.com//api/v1/extract \ -H "X-API-Key: ine_tu_api_key" \ -F "image_front=@./ine_frente.jpg" \ -F "image_back=@./ine_reverso.jpg"
Base64 JSON
Envia imagenes codificadas en base64. El prefijo data URL es opcional.
| Campo | Tipo | Descripcion |
|---|---|---|
image_front | string | Base64 de imagen frontal (requerido) |
image_back | string | Base64 de imagen trasera (opcional) |
# Codificar imagen a base64
IMAGE_BASE64=$(base64 -i ine_frente.jpg)
curl -X POST https://extraerdatosdeine.com//api/v1/extract \
-H "X-API-Key: ine_tu_api_key" \
-H "Content-Type: application/json" \
-d "{\"image_front\": \"$IMAGE_BASE64\"}"URL Fetch
Envia URLs de imagenes hospedadas. Solo se permiten URLs HTTPS.
| Campo | Tipo | Descripcion |
|---|---|---|
image_front_url | string | URL HTTPS de imagen frontal (requerido) |
image_back_url | string | URL HTTPS de imagen trasera (opcional) |
curl -X POST https://extraerdatosdeine.com//api/v1/extract \
-H "X-API-Key: ine_tu_api_key" \
-H "Content-Type: application/json" \
-d '{
"image_front_url": "https://storage.example.com/ine_frente.jpg",
"image_back_url": "https://storage.example.com/ine_reverso.jpg"
}'Upload Binario
Envia la imagen como body binario. Solo soporta una imagen por peticion.
curl -X POST https://extraerdatosdeine.com//api/v1/extract \ -H "X-API-Key: ine_tu_api_key" \ -H "Content-Type: image/jpeg" \ --data-binary @./ine_frente.jpg
Respuesta exitosa
{
"success": true,
"extraction_id": "clx1234567890",
"data": {
"nombre": "JUAN",
"apellidoPaterno": "PEREZ",
"apellidoMaterno": "GARCIA",
"curp": "PEGJ850101HDFRRL09",
"claveElector": "PRGRJN85010109H100",
"fechaNacimiento": "01/01/1985",
"sexo": "H",
"domicilio": "CALLE EJEMPLO 123",
"colonia": "CENTRO",
"codigoPostal": "06000",
"municipio": "CUAUHTEMOC",
"estado": "CIUDAD DE MEXICO",
"seccion": "1234",
"vigencia": "2029",
"numeroVertical": "1234567890123",
"ocr": "1234567890123",
"cic": "123456789",
"emision": "01"
},
"tokens_remaining": 19,
"upload_method": "multipart"
}/api/v1/balanceObtiene el saldo actual de tokens de tu cuenta.
Ejemplo
curl https://extraerdatosdeine.com//api/v1/balance \ -H "X-API-Key: ine_tu_api_key"
Respuesta
{
"success": true,
"balance": 20
}Ejemplos de Integracion
JavaScript / Node.js
// Usando fetch con FormData
const formData = new FormData();
formData.append('image_front', fileInput.files[0]);
const response = await fetch('https://extraerdatosdeine.com//api/v1/extract', {
method: 'POST',
headers: {
'X-API-Key': 'ine_tu_api_key'
},
body: formData
});
const result = await response.json();
console.log(result.data);Python
import requests
url = 'https://extraerdatosdeine.com//api/v1/extract'
headers = {'X-API-Key': 'ine_tu_api_key'}
# Usando archivos (multipart)
files = {
'image_front': open('ine_frente.jpg', 'rb'),
'image_back': open('ine_reverso.jpg', 'rb')
}
response = requests.post(url, headers=headers, files=files)
result = response.json()
print(result['data'])PHP
<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => 'https://extraerdatosdeine.com//api/v1/extract',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => ['X-API-Key: ine_tu_api_key'],
CURLOPT_POSTFIELDS => [
'image_front' => new CURLFile('ine_frente.jpg'),
'image_back' => new CURLFile('ine_reverso.jpg')
]
]);
$response = curl_exec($curl);
$result = json_decode($response, true);
print_r($result['data']);Codigos de error
| Codigo | HTTP | Descripcion |
|---|---|---|
MISSING_API_KEY | 401 | No se proporciono API key |
INVALID_API_KEY | 401 | API key invalida o revocada |
MISSING_IMAGE | 400 | No se proporciono imagen frontal |
INVALID_IMAGE_FORMAT | 400 | Formato no soportado (use JPEG, PNG o WebP) |
IMAGE_TOO_LARGE | 400 | Imagen excede 10 MB |
INVALID_BASE64 | 400 | Error al decodificar base64 |
INVALID_MULTIPART | 400 | Error al procesar formulario multipart |
URL_FETCH_FAILED | 400 | No se pudo obtener imagen de la URL |
URL_INVALID | 400 | URL invalida (debe ser HTTPS) |
URL_BLOCKED | 400 | URL bloqueada por seguridad |
URL_TIMEOUT | 400 | Timeout al obtener imagen (10s) |
UNSUPPORTED_CONTENT_TYPE | 415 | Content-Type no soportado |
INSUFFICIENT_TOKENS | 402 | Saldo insuficiente de tokens |
EXTRACTION_FAILED | 500 | Error en la extraccion (token reembolsado) |
INTERNAL_ERROR | 500 | Error interno del servidor |
Campos extraidos
La API extrae los siguientes campos de la credencial INE/IFE:
nombreNombre(s)
apellidoPaternoApellido paterno
apellidoMaternoApellido materno
curpCURP (18 caracteres)
claveElectorClave de elector
fechaNacimientoFecha de nacimiento
sexoSexo (H/M)
domicilioDomicilio completo
calleCalle
coloniaColonia
codigoPostalCodigo postal
municipioMunicipio/Alcaldia
estadoEstado
seccionSeccion electoral
anioRegistroAno de registro
vigenciaVigencia
numeroVerticalNumero vertical
ocrCodigo OCR
cicCodigo CIC
emisionNumero de emision
Limites y cuotas
- Cada extraccion consume 1 token
- Tamano maximo de imagen: 10MB
- Formatos soportados: JPEG, PNG, WebP
- Timeout para URL fetch: 10 segundos
- Si una extraccion falla por un error del sistema, el token se reembolsa automaticamente
- Los tokens no expiran