Reference
Please note that these two packages are open source and that you can also find more detailed information in the correspondent repositories of both carto-auth and pydeck-carto packages.
carto-auth
The carto-auth library provides two types of authentication methods with your CARTO account.
CartoAuth.from_oauth
Create a CartoAuth object using OAuth with CARTO.
Parameters
cache_filepath (str, optional): File path where the token is stored. Default “home()/.carto-auth/token_auth.json”.
use_cache (bool, optional): Whether the stored cached token should be used. Default True.
open_browser (bool, optional): Whether the web browser should be opened to authorize a user. Default True.
api_base_url (str, optional): Base URL for a CARTO account.
org (str, optional): Single Sign-On (SSO) organization in CARTO.
Return type
CartoAuth
Examples
CartoAuth.from_m2m
Create a CartoAuth object using a credentials file to login to the CARTO account.
Parameters
filepath (str): File path of the CARTO credentials file.
cache_filepath (str, optional): File path where the token is stored. Default “home()/.carto-auth/token_m2m.json”.
use_cache (bool, optional): Whether the stored cached token should be used. Default True.
Return type
CartoAuth
Raises
AttributeError: If the CARTO credentials file does not contain the following attributes: “api_base_url”, “client_id”, “client_secret”.
ValueError: If the CARTO credentials file does not contain any attribute value.
Example
get_api_base_url
Method to get the API Base URL of the current CARTO session.
Return type
Str
Example
get_access_token
Method to get the token of the current CARTO session.
Return type
Str
Example
get_carto_dw_client
Returns a client to query directly the CARTO Data Warehouse using the BigQuery client.
It requires extra dependencies carto-auth[carto-dw] to be installed.
Return type
Client
Example
get_carto_dw_credentials
Get the CARTO Data Warehouse credentials.
Return type
tuple
Raises
CredentialsError: If the API Base URL is not provided.
Example
pydeck-carto
The pydeck-carto package is a wrapper of pydeck that uses the CartoLayer to enable visualizing tables and tilesets available in your cloud data warehouses as map layers within your data science workflows in Python notebooks. It provides access to the data available in the connections created in the CARTO platform, and it allows you to build visualizations with several pre-built color styling functions.
register_carto_layer
Add CartoLayer JS bundle to pydeck’s custom libraries.
Example
get_layer_credentials
Get the layer credentials object to gather information from Carto warehouses.
Example
styles.color_bins
Helper function for quickly creating a color bins style.
Data values of each attribute are rounded down to the nearest value in the domain and are then styled with the corresponding color.
Parameters
attr (str): Attribute or column to symbolize by.
domain (list): Assign manual class break values.
colors (Union[str, list], optional): Color assigned to each domain value. - str: A valid named CARTOColors palette. - list: Array of colors in RGBA [ [r, g, b, [a]] ]. Default is PurpOr.
null_color (list, optional): Color for null values. Default is [204, 204, 204].
Example
styles.color_categories
Helper function for quickly creating a color category style.
Data values of each attribute listed in the domain are mapped one to one with corresponding colors in the range.
Parameters
attr (str): Attribute or column to symbolize by.
domain (list): Category list. Must be a valid list of categories.
colors (Union[str, list], optional): Color assigned to each domain value. - str: A valid named CARTOColors palette. - list: Array of colors in RGBA [ [r, g, b, [a]] ]. Default: PurpOr.
null_color (list, optional): Color for null values. Default is [204, 204, 204].
others_color (list, optional): Fallback color for a category not correctly assigned. Default is [119, 119, 119].
Example
styles.color_continuous
Helper function for quickly creating a color continuous style.
Data values of each field are interpolated linearly across values in the domain and are then styled with a blend of the corresponding color in the range.
Parameters
attr (str): Attribute or column to symbolize by.
domain (list): Attribute domain to define the data range.
colors (Union[str, list], optional): Color assigned to each domain value. - str: A valid named CARTOColors palette. - list: Array of colors in RGBA [ [r, g, b, [a]] ]. Default is PurpOr.
null_color (list, optional): Color for null values. Default is [204, 204, 204].
Example
Last updated