The Foundry API is currently in an experimental release. The endpoints documented here may be subject to breaking changes in the future.
With the Foundry API, you can programmatically place spot instance bids to dynamically scale your compute. A full version of this API will ship in the coming months, but this Jupyter notebook (replicated below) will help you get started.
#First you'll need to login to grab your access token. You can do this by running the following code block.
conn = http.client.HTTPSConnection(API_URL)
data = {'email': 'YOUR_EMAIL', 'password': 'YOUR_PASSWORD'}
payload = json.dumps(data)
conn.request("POST", "/login", payload)
res = conn.getresponse()
data = json.loads(res.read().decode("utf-8"))
access_token = data["access_token"]
user_id = foundryGet("/users/")["id"]
projects = foundryGet("/users/" + str(user_id) + "/projects")
#Assuming the first project
project_id = projects[0]["id"]
#Grab all your instances
all_instances = foundryGet("/projects/" + str(project_id) + "/all_instances")
#Grab available auctions
auctions = foundryGet("/projects/" + str(project_id) + "/spot-auctions/auctions")
#Grab your ssh keys
ssh_keys = foundryGet("/projects/" + str(project_id) + "/ssh_keys")
#Using the first ssh_key for now
ssh_key_id = ssh_keys[0]["id"]