API endpoints in Medusa is a place for developers to add custom logic that HTTP requests can trigger. The endpoints have direct access to Medusa’s core services like the Product and Cart services and custom services added to your project or in installed plugins.
API Routes will drastically simplify creating custom API endpoints.
Developers will be able to create custom routes using simple JavaScript without worrying about the intricacies of the Express Router. Routes are registered using the file system, an approach familiar to many from frameworks like Next.js and Svelte.
API endpoints in Medusa is a place for developers to add custom logic that HTTP requests can trigger. The endpoints have direct access to Medusa’s core services like the Product and Cart services and custom services added to your project or in installed plugins.
API Routes will drastically simplify creating custom API endpoints.
Developers will be able to create custom routes using simple JavaScript without worrying about the intricacies of the Express Router. Routes are registered using the file system, an approach familiar to many from frameworks like Next.js and Svelte.
Here's a basic example of the API:
The example above illustrates a few key points of API Routes:
route.{ts|js}
is a special file that contains the router handlersGET
In the example above, we register a
GET
route at path/admin/products
.