Morpheus API Calls from Python

I use Python to interact with Morpheus for internal and external clients and I wanted an easy way to make calls to the Morpheus API without dealing with Python requests. Enter pymorpheus, an easy Python module to act as a wrapper to the Morpheus API.

If I wanted to get a list of instances with a phrase matching “test”, it’s super easy:

from pymorpheus import MorpheusClient
morpheus = MorpheusClient("https://yoururl", username="youruser", password="yourpass")
results ="get", path="instances", options=[("phrase","testing")])

Adding json payloads to POST calls is handled within the same call as well. You can also use a token to authenticate.

1 Like

How do I install pymorpheus?

pip install pymorpheus


@jwheeler 's solution will work for user level. If using it in a Python task in Morpheus, you can put pymorpheus into the Additional Packages box of the task.

Instead of username, password and url, can we use morpheus[‘morpheus’][‘apiAccessToken’] and morpheus[‘morpheus’][‘applianceUrl’] ?

Absolutely. Those will be ephemeral for the duration of the task.

1 Like

Thanks for sharing! Is the source available anywhere?

As a matter of fact, it is!

It’s just a wrapper to make requests easier to deal with. Not incredibly robust.