Authentication / Autenticación
Secure your API requests with proper authentication.
Asegura tus solicitudes API con autenticación adecuada.
API Key Authentication / Autenticación con Llave API
The LosCenotes Partner API uses API keys to authenticate requests.
La API de Partners de LosCenotes usa llaves API para autenticar solicitudes.
X-API-Key Header
Include your API key in the X-API-Key header:
Incluye tu llave API en el header X-API-Key:
X-API-Key: pk_live_your_api_key
Example Request / Ejemplo de Solicitud
curl -X GET "https://service-gateway.loscenotes.com/partner/cenotes" \
-H "X-API-Key: pk_live_your_api_key" \
-H "Content-Type: application/json"
API Key Format / Formato de Llave API
Production Keys / Llaves de Producción
- Prefix / Prefijo:
pk_live_ - Purpose / Propósito: Live production environment / Ambiente de producción
- Features / Características:
- Real transactions / Transacciones reales
- Standard rate limits / Límites de tasa estándar
- Production data access / Acceso a datos de producción
Example / Ejemplo:
pk_live_abc123def456ghi789jkl012mno345pqr678stu
Security Best Practices / Mejores Prácticas de Seguridad
1. Keep Your Keys Secure / Mantén tus Llaves Seguras
⚠️ Warning / Advertencia
Never expose your API keys in:
Nunca expongas tus llaves API en:
- Client-side code / Código del lado del cliente
- Public repositories / Repositorios públicos
- Mobile applications / Aplicaciones móviles
- Browser JavaScript / JavaScript en el navegador
2. Use Environment Variables / Usa Variables de Entorno
// Good ✓ / Correcto ✓
const apiKey = process.env.LOSCENOTES_API_KEY;
// Bad ✗ / Incorrecto ✗
const apiKey = "pk_live_1234567890abcdef";
3. Rotate Keys Regularly / Rota Llaves Regularmente
- Generate a new API key / Genera una nueva llave API
- Update your application / Actualiza tu aplicación
- Verify everything works / Verifica que todo funcione
- Revoke the old key / Revoca la llave anterior
Error Responses / Respuestas de Error
Invalid API Key / Llave API Inválida
HTTP Status: 401 Unauthorized
{
"success": false,
"error": {
"code": "INVALID_API_KEY",
"message": "The provided API key is invalid",
"status": 401
}
}
Missing Authentication / Autenticación Faltante
HTTP Status: 401 Unauthorized
{
"success": false,
"error": {
"code": "AUTHENTICATION_REQUIRED",
"message": "Authentication is required for this endpoint",
"status": 401
}
}
Insufficient Permissions / Permisos Insuficientes
HTTP Status: 403 Forbidden
{
"success": false,
"error": {
"code": "INSUFFICIENT_PERMISSIONS",
"message": "Your API key doesn't have permission for this action",
"status": 403
}
}
Testing Authentication / Probando Autenticación
Test your authentication setup with a simple request:
Prueba tu configuración de autenticación con una solicitud simple:
curl -X GET "https://service-gateway.loscenotes.com/partner/cenotes" \
-H "X-API-Key: pk_live_your_api_key" \
-H "Content-Type: application/json"
Successful response / Respuesta exitosa:
{
"success": true,
"message": "cenotes.list_retrieved_successfully",
"data": [...],
"pagination": {
"total": 25,
"perPage": 10,
"currentPage": 1,
"lastPage": 3
}
}
Code Examples / Ejemplos de Código
JavaScript / Node.js
const response = await fetch('https://service-gateway.loscenotes.com/partner/cenotes', {
method: 'GET',
headers: {
'X-API-Key': process.env.LOSCENOTES_API_KEY,
'Content-Type': 'application/json',
'Accept-Language': 'es'
}
});
const data = await response.json();
if (!data.success) {
console.error('Error:', data.error.message);
} else {
console.log('Cenotes:', data.data);
}
Python
import os
import requests
api_key = os.environ.get('LOSCENOTES_API_KEY')
response = requests.get(
'https://service-gateway.loscenotes.com/partner/cenotes',
headers={
'X-API-Key': api_key,
'Content-Type': 'application/json',
'Accept-Language': 'es'
}
)
data = response.json()
if data['success']:
print('Cenotes:', data['data'])
else:
print('Error:', data['error']['message'])
PHP
<?php
$apiKey = getenv('LOSCENOTES_API_KEY');
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => 'https://service-gateway.loscenotes.com/partner/cenotes',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'X-API-Key: ' . $apiKey,
'Content-Type: application/json',
'Accept-Language: es'
]
]);
$response = curl_exec($ch);
curl_close($ch);
$data = json_decode($response, true);
if ($data['success']) {
print_r($data['data']);
} else {
echo 'Error: ' . $data['error']['message'];
}