I want to create a REST API that is not bound to a model

I have found plenty of examples of using the DRF for views bound to models, but none that do just calculations or transformation. i.e. a URL to

/myapp/api/dosomething/ with either a GET method or a POST method that accepts a request, looks at the data in the request, does something and returns a response.

I created three files

/myapp/api/atomicservice1.py
/myapp/api/atomicservice2.py
/myapp/api/atomicservice3.py

class DoSomething:
def process_request(request):

requestmethod = request.method
print(‘requestmethod=’, requestmethod)

    if requestmethod == 'POST':
        print()
        print("******************************************")
        mybody = str(request.body)
        print("mybody=", mybody)
        decoded_body = urllib.parse.parse_qs(mybody)
        print()
        print("decoded_body=",decoded_body)
        print("******************************************")
        print()

how do I create the response to return?

You probably don’t even need DRF for that. That could be a regular Django view that returns a JsonResponse. (If you’re already using DRF for the rest of your application, you could create this as an APIView class returning a DRF Response object.)

ok good to know. I guess I need an example.

There are examples of each in the referenced docs.

Ok Ken,

Thanks, I did find one in the DRF docs for function based views.