DEV Community

Alex Spinov
Alex Spinov

Posted on

Medusa Has a Free E-Commerce API That Replaces Shopify for Developers

Medusa is an open-source headless commerce engine with a modular API. Build custom storefronts with full control over the shopping experience — no Shopify limitations.

Setup

npx create-medusa-app my-store
cd my-store
npx medusa develop
# API at http://localhost:9000
# Admin at http://localhost:7001
Enter fullscreen mode Exit fullscreen mode

Storefront API

import Medusa from '@medusajs/medusa-js';

const medusa = new Medusa({ baseUrl: 'http://localhost:9000', maxRetries: 3 });

// List products
const { products } = await medusa.products.list({ limit: 20 });

// Get product with variants
const { product } = await medusa.products.retrieve(productId);
console.log(product.title, product.variants.map(v => v.prices));

// Create cart
const { cart } = await medusa.carts.create();

// Add item
await medusa.carts.lineItems.create(cart.id, {
  variant_id: 'variant_123',
  quantity: 2
});

// Complete checkout
await medusa.carts.update(cart.id, {
  email: 'customer@example.com',
  shipping_address: { first_name: 'Alice', last_name: 'Smith', address_1: '123 Main St', city: 'NYC', country_code: 'us', postal_code: '10001' }
});

const { data } = await medusa.carts.complete(cart.id);
Enter fullscreen mode Exit fullscreen mode

REST API Direct

# Products
curl http://localhost:9000/store/products

# Create cart
curl -X POST http://localhost:9000/store/carts

# Add to cart
curl -X POST http://localhost:9000/store/carts/{id}/line-items \
  -d '{"variant_id":"var_123","quantity":1}'
Enter fullscreen mode Exit fullscreen mode

Custom API Routes

// src/api/store/custom/route.ts
import type { MedusaRequest, MedusaResponse } from '@medusajs/medusa';

export async function GET(req: MedusaRequest, res: MedusaResponse) {
  const productService = req.scope.resolve('productService');
  const products = await productService.list({ status: 'published' });
  res.json({ products });
}
Enter fullscreen mode Exit fullscreen mode

Why This Matters

  • No vendor lock-in: Own your commerce infrastructure
  • Fully customizable: Extend any part of the API
  • Multi-region: Built-in support for multiple currencies and regions
  • Plugin ecosystem: Payments, fulfillment, notifications

Need custom e-commerce tools or API integrations? I build developer tools. Check out my web scraping actors on Apify or reach out at spinov001@gmail.com for custom solutions.

Top comments (0)