Skip to main content

How to add routes

First we create a new folder called routes in the src directory. And make a new file hello-world

const { methods, Route } = require('@sapphire/plugin-api');

class UserRoute extends Route {
constructor(context, options) {
super(context, {
route: 'hello-world'

[methods.GET](_request, response) {
response.json({ message: 'Hello World' });

[methods.POST](_request, response) {
response.json({ message: 'Hello World' });
module.exports = {

A quick glance on what we did above:

  • First we extended the Route class to make our route
  • Second we specified the route name in the constructor
  • Third we defined the GET method
  • Finally we responded to the request with a message which we would be able to use later when we fetch the route