Get All Products
curl -X GET "https://api.miscompras.com/api/productos"
Retrieve all products from the marketplace.
Response
Returns an array of product objects.
Array of product objects Unique product identifier
Success Response
Error Response
[
{
"id_producto" : 1 ,
"nombre" : "iPhone 15 Pro" ,
"descripcion" : "Latest Apple smartphone with A17 Pro chip" ,
"precio" : 999.99 ,
"imagen" : "1704123456_abc123def456.jpg" ,
"id_vendedor" : 5 ,
"id_categoria" : 1 ,
"stock" : 10
},
{
"id_producto" : 2 ,
"nombre" : "Samsung Galaxy S24" ,
"descripcion" : "Premium Android smartphone" ,
"precio" : 849.99 ,
"imagen" : "1704123789_def789ghi012.jpg" ,
"id_vendedor" : 3 ,
"id_categoria" : 1 ,
"stock" : 15
}
]
Get Product by ID
GET /php/obtener_producto.php
curl -X GET "https://api.miscompras.com/php/obtener_producto.php?id=1"
Retrieve detailed information about a specific product.
Query Parameters
The unique identifier of the product
Response
Indicates whether the product was found
Product information (only present when found) Product’s unique identifier
Success Response
Error - Not Found
{
"exito" : true ,
"producto" : {
"id_producto" : 1 ,
"nombre" : "iPhone 15 Pro" ,
"precio" : 999.99 ,
"descripcion" : "Latest Apple smartphone with A17 Pro chip" ,
"imagen" : "1704123456_abc123def456.jpg"
}
}
Search Products
GET /php/buscar_productos.php
curl -X GET "https://api.miscompras.com/php/buscar_productos.php?q=iphone"
Search for products by name, description, or price.
Query Parameters
Search term to match against product name, description, or price
Response
Indicates whether the search was successful
Array of matching products
Success Response
Empty Search
{
"exito" : true ,
"productos" : [
{
"id_producto" : 1 ,
"nombre" : "iPhone 15 Pro" ,
"precio" : 999.99 ,
"imagen" : "1704123456_abc123def456.jpg"
},
{
"id_producto" : 5 ,
"nombre" : "iPhone 14" ,
"precio" : 799.99 ,
"imagen" : "1704123999_xyz789abc123.jpg"
}
]
}
The search uses SQL LIKE matching and searches across product name, description, and price fields.
Get Products by Category
GET /php/obtener_productos_por_categoria.php
curl -X GET "https://api.miscompras.com/php/obtener_productos_por_categoria.php"
Retrieve all products grouped by category.
Response
Array of category groups Category name (or “Sin categoría” for uncategorized)
Array of products in this category
{
"exito" : true ,
"categorias" : [
{
"categoria" : "Electrónicos" ,
"productos" : [
{
"id_producto" : 1 ,
"nombre" : "iPhone 15 Pro" ,
"descripcion" : "Latest Apple smartphone" ,
"precio" : 999.99 ,
"imagen" : "1704123456_abc123def456.jpg" ,
"id_vendedor" : 5 ,
"vendedor" : "TechStore"
}
]
},
{
"categoria" : "Hogar" ,
"productos" : [
{
"id_producto" : 10 ,
"nombre" : "Aspiradora Robot" ,
"descripcion" : "Robot vacuum cleaner" ,
"precio" : 299.99 ,
"imagen" : "1704124000_robot123.jpg" ,
"id_vendedor" : 8 ,
"vendedor" : "HomeGoods"
}
]
}
]
}
Get Categories
GET /php/obtener_categorias.php
curl -X GET "https://api.miscompras.com/php/obtener_categorias.php"
Retrieve all available product categories.
Response
Array of category objects
{
"exito" : true ,
"categorias" : [
{
"id_categoria" : 1 ,
"nombre" : "Electrónicos"
},
{
"id_categoria" : 2 ,
"nombre" : "Hogar"
},
{
"id_categoria" : 3 ,
"nombre" : "Deportes"
}
]
}
Create Product
curl -X POST https://api.miscompras.com/php/vender.php \
-H "Content-Type: multipart/form-data" \
-F "nombre=Laptop HP Pavilion" \
-F "descripcion=15.6 inch, 16GB RAM, 512GB SSD" \
-F "precio=799.99" \
-F "categoria=1" \
-F "id_vendedor=5" \
-F "imagen=@laptop.jpg"
Create a new product listing. Requires an active session or seller ID.
Request Parameters
Category ID (optional, can be null)
Product image file (uploaded as multipart/form-data)
Seller’s user ID (can be obtained from session)
Response
Alternative success indicator
Alternative result message
Success Response
Error - No Session
Error - Missing Fields
{
"success" : true ,
"exito" : true ,
"message" : "✅ Producto publicado correctamente." ,
"mensaje" : "Producto publicado correctamente."
}
The image is stored with a unique filename using timestamp and random bytes to prevent collisions.
Update Product
POST /php/actualizar_producto.php
curl -X POST https://api.miscompras.com/php/actualizar_producto.php \
-H "Content-Type: multipart/form-data" \
-F "id_producto=1" \
-F "nombre=iPhone 15 Pro Max" \
-F "precio=1099.99" \
-F "descripcion=Updated description" \
-F "imagen=@new_image.jpg"
Update an existing product. Image upload is optional.
Request Parameters
ID of the product to update
New product image (optional - if not provided, keeps existing image)
Response
Error message (only on failure)
Success Response
Error Response
Delete Product
POST /php/eliminar_producto.php
curl -X POST https://api.miscompras.com/php/eliminar_producto.php \
-H "Content-Type: application/json" \
-d '{"id_producto": 1}'
Delete a product from the marketplace.
This endpoint accepts the product ID via POST body (JSON), GET query parameter, or form data.
Request Parameters
ID of the product to delete
Response
Success Response
Error - Invalid ID
Error - Delete Failed
{
"exito" : true ,
"mensaje" : "Producto eliminado correctamente."
}
Deleting a product is permanent and cannot be undone. Ensure you have proper authorization checks in place.
Get Featured Products by Category
GET /php/obtener_destacados_por_categoria.php
curl -X GET "https://api.miscompras.com/php/obtener_destacados_por_categoria.php"
Retrieves the top 3 most recent products for each category.
Response
Array of category objects with featured products Array of up to 3 featured products from this category
{
"exito" : true ,
"categorias" : [
{
"id_categoria" : 2 ,
"categoria" : "Laptops" ,
"productos" : [
{
"id_producto" : 2 ,
"nombre" : "MacBook Pro M3" ,
"descripcion" : "Chip M3, pantalla Retina, 16GB RAM, SSD 512GB" ,
"precio" : "1599.99" ,
"imagen" : "macbook.jpg" ,
"id_vendedor" : null ,
"vendedor" : null ,
"fecha_publicacion" : "2025-12-26 12:04:08"
}
]
},
{
"id_categoria" : 3 ,
"categoria" : "Smartphones" ,
"productos" : [
{
"id_producto" : 1 ,
"nombre" : "iPhone 15 Pro" ,
"descripcion" : "Chip A17 Pro, cámara de 48MP, titanio" ,
"precio" : "999.99" ,
"imagen" : "iphone15.jpg" ,
"id_vendedor" : null ,
"vendedor" : null ,
"fecha_publicacion" : "2025-12-26 12:04:08"
}
]
}
]
}
This endpoint is useful for homepage displays showing featured products from each category. Products are ordered by most recent publication date within each category.