This example illustrate how to publish a visualization using a private table. Using private tables requires to create Maps API keys for the visualization. By default it creates a custom Maps API key for all the private tables used in the visualization if not provided.
Read more about Maps API Keys: https://carto.com/developers/auth-api/guides/types-of-API-Keys/
Note: You'll need CARTO Account credentials to reproduce this example.
from cartoframes.auth import set_default_credentials
set_default_credentials('creds.json')
from cartoframes.viz import Map, Layer
map_viz = Map(Layer('private_table'))
map_viz.publish(
name='map_private_table',
password='1234',
if_exists='replace')
The map has been published. The "cartoframes_997c05771fd4e0916de49826722e51cd" Maps API key with value "7rj9ftFsOKUjSotnygh2jg" is being used for the datasets: "private_table". You can manage your API keys on your account.
{'id': 'd5511e5e-f64f-4b87-b970-3ba7a36a62f1', 'url': 'https://cartoframes-org.carto.com/u/cartoframes/kuviz/d5511e5e-f64f-4b87-b970-3ba7a36a62f1', 'name': 'map_private_table', 'privacy': 'password'}
The Maps API key can be created in the CARTO Dashboard and provided to the method.
map_viz.publish(
name='map_private_table',
password='1234',
if_exists='replace',
maps_api_key='7rj9ftFsOKUjSotnygh2jg')
{'id': 'd5511e5e-f64f-4b87-b970-3ba7a36a62f1', 'url': 'https://cartoframes-org.carto.com/u/cartoframes/kuviz/d5511e5e-f64f-4b87-b970-3ba7a36a62f1', 'name': 'map_private_table', 'privacy': 'password'}