Skip to main content

Tu primera petición

Una vez que hayas configurado la autenticación, es hora de hacer tu primera petición a la API de E3 Stores.

Paso a paso

1. Obtener el hash de autenticación

Primero, autentica con la API para obtener tu hash token:

curl -X GET "https://demo.e3stores.cloud/Api/Auth/?username=TestApi&password=TestApi5867"

2. Consultar el inventario

Ahora usa el hash para consultar el inventario completo:

curl -X GET "https://demo.e3stores.cloud/api/inventory?hash=5de3928b-6018-4b0c-9ebd-bc2c3e18f708"

3. Interpretar la respuesta

La respuesta incluirá un array con todos los productos del inventario.

Ejemplo completo en JavaScript

async function firstAPICall() {
// 1. Autenticación
const authResponse = await fetch(
'https://demo.e3stores.cloud/Api/Auth/?username=TestApi&password=TestApi5867'
);
const authData = await authResponse.json();

if (authData.status !== 'success') {
throw new Error('Authentication failed');
}

const hash = authData.data;
console.log('Hash obtenido:', hash);

// 2. Consultar inventario
const inventoryResponse = await fetch(
`https://demo.e3stores.cloud/api/inventory?hash=${hash}`
);
const inventory = await inventoryResponse.json();

console.log('Productos en inventario:', inventory.length);
console.log('Primer producto:', inventory[0]);
}

// Ejecutar
firstAPICall().catch(console.error);

Siguientes pasos

¡Excelente! Ya has hecho tu primera petición exitosa. Ahora puedes:

  1. Explorar otros endpoints disponibles
  2. Aprender sobre manejo de errores
  3. Ver ejemplos avanzados