Getting Started with the REST API
Last updated
Was this helpful?
Was this helpful?
pip install requestspython --version# Linux/Mac
export VH_API_TOKEN=your_token_value
# Windows
set VH_API_TOKEN=your_token_valueimport requests
import json
import os
# Retrieve your authentication token
auth_token = os.environ["VH_API_TOKEN"]
headers = {"Authorization": f"Token {auth_token}"}
# Fetch all projects
resp = requests.get("https://app.valohai.com/api/v0/projects/", headers=headers)
resp.raise_for_status()
print(json.dumps(resp.json(), indent=4))python test.pycurl -H "Authorization: Token YOUR_TOKEN_HERE" https://app.valohai.com/api/v0/projects/{
"count": 1,
"next": null,
"previous": null,
"results": [
{
"id": "015f25c1-0101-1010-fefe-a0a0a0a0a0a0",
"name": "my-project",
"description": "",
"owner": {
"id": 1337,
"username": "myusername"
},
"ctime": "2017-10-16T15:16:19.230872Z",
"mtime": "2017-10-16T15:16:19.230895Z",
"url": "https://app.valohai.com/api/v0/projects/015f25c1-0101-1010-fefe-a0a0a0a0a0a0/",
"urls": {
"display": "https://app.valohai.com/p/myusername/my-project/",
"display_repository": "https://app.valohai.com/p/myusername/my-project/settings/repository/"
},
"execution_count": 0,
"last_execution_ctime": null
}
]
}