Here's some example code that shows you how to call the Domino REST API to get info on your current user, from within a Domino interactive workspace or batch run. This example can be copied into a python notebook or script and should run without modification inside of a Domino run or workspace, since we provide all the required environment variables by default.
import requests import json import os DOMINO_USER_API_KEY = os.environ['DOMINO_USER_API_KEY'] HOST = os.environ['DOMINO_API_HOST'] URL = HOST + '/v4/users/self' headers={'X-Domino-Api-Key':DOMINO_USER_API_KEY} out=requests.get(url=URL,headers=headers) out.json()
And here's a screenshot showing this in a Domino Jupyter session
As always, please take care with your API key and treat it as a password (don't print it out in your notebook!)
Give the approach above a try and let us know if you have any questions or feedback.
If you are looking for examples that use Python3 and work 5.x+ versions of Domino, please see API Examples for Domino 5.x.
Comments
0 comments
Please sign in to leave a comment.