Calling Domino REST API from Python/Jupyter

katie.shakman
katie.shakman Administrator, Domino Posts: 257 admin
edited April 2020 in Tutorials & Best Practices

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.

Katie

Field Data Scientist @ Domino

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!