WARNING

It is a non-public API. It may change with no previous notice

We are going to show how to work with the CARTO custom visualizations (aka Kuviz).

We are going to start creating tje Auth client and we will use it in every example.

You only need to complete the following cell:


In [ ]:
USERNAME = ""
BASE_URL = "https://{u}.carto.com".format(u=USERNAME)
API_KEY = ""

In [ ]:
from carto.auth import APIKeyAuthClient

auth_client = APIKeyAuthClient(api_key=API_KEY, base_url=BASE_URL)

Kuviz manager creation


In [ ]:
from carto.kuvizs import KuvizManager

km = KuvizManager(auth_client)

Create public Kuviz


In [ ]:
html = "<html><body><h1>Working with CARTO Kuviz</h1></body></html>"
public_kuviz = km.create(html=html, name="kuviz-public-test")

print(public_kuviz.id)
print(public_kuviz.url)
print(public_kuviz.privacy)

Create Kuviz protected by password


In [ ]:
html = "<html><body><h1>Working with CARTO Kuviz</h1></body></html>"
password_kuviz = km.create(html=html, name="kuviz-password-test", password="1234")

print(password_kuviz.id)
print(password_kuviz.url)
print(password_kuviz.privacy)

Update a kuviz


In [ ]:
new_html = "<html><body><h1>Another HTML</h1></body></html>"
password_kuviz.data = new_html
password_kuviz.save()

print(password_kuviz.id)
print(password_kuviz.url)
print(password_kuviz.privacy)

If you want to remove the password:


In [ ]:
password_kuviz.password = None
password_kuviz.save()

print(password_kuviz.id)
print(password_kuviz.url)
print(password_kuviz.privacy)

And if you want to add the password again:


In [ ]:
password_kuviz.password = "1234"
password_kuviz.save()

print(password_kuviz.id)
print(password_kuviz.url)
print(password_kuviz.privacy)

Delete a kuviz


In [ ]:
password_kuviz.delete()