API Docs


You can execute notebook with REST API call and return JSON response from notebook. The APIResponse object is use to return JSON. It will be returned as REST API response. What is more, the JSON will be displayed in the notebook.

import mercury as mr
# return JSON response
response = mr.APIResponse({"message": "Hello from Mercury!", 
                           "description": "Execute notebook with REST API return JSON as response"})

In the notebook the APIResponse is displayed as JSON:

Return JSON response from Jupyter Notebook executed with REST API

You can serve notebook as REST API endpoint with Mercury. In this case, the APIResponse will define JSON response from enpoint.