Path Parameter

Route path parameters are declared in python format-strings. for example:

from ninja_extra import api_controller, route
from ninja import constants


@api_controller('', tags=['My Operations'], auth=constants.NOT_SET, permissions=[])
class MyAPIController:
    @route.get('/users/{user_id}')
    def get_user_by_id(self, user_id: int):
        return {'user_id': user_id}

The value of the path parameter user_id will be passed to your function as the argument user_id.

Info

Read more