Full Class and Function docs

Baserow Client

class baserowapi.baserow.Baserow(url: str = 'https://api.baserow.io', token: str | None = None, logging_level: int = 30, log_file: str | None = None, batch_size: int = 10)[source]

Bases: object

A client class for interacting with the Baserow API.

Variables:
  • url (str) – The base URL for the Baserow API.

  • token (str) – The authentication token.

  • ERROR_MESSAGES (dict) – A dictionary mapping HTTP error codes to error messages.

ERROR_MESSAGES: Dict[int, str] = {400: 'Bad request to {url}. The request contains invalid values or the JSON could not be parsed.', 401: 'Unauthorized request to {url}. Accessing an endpoint without a valid database token.', 404: 'Resource not found at {url}. Row or table is not found.', 413: 'Request entity too large at {url}. The request exceeded the maximum allowed payload size.', 415: 'Unsupported media type in request at {url}.', 500: 'Internal server error at {url}. The server encountered an unexpected condition.', 502: 'Bad gateway at {url}. Baserow is restarting or an unexpected outage is in progress.', 503: 'Service unavailable at {url}. The server could not process your request in time.'}
configure_logging(level: int, log_file: str | None) None[source]

Configure logging for the Baserow client.

Parameters:
  • level (int) – The logging level.

  • log_file (str, optional) – The path to a log file. If provided, logs will also be written to this file.

get_combined_headers(additional_headers: Dict[str, str] | None) Dict[str, str][source]

Combines the default headers with any additional headers provided.

Parameters:

additional_headers (dict, optional) – Additional headers to combine with the default headers.

Returns:

Combined headers.

Return type:

dict

get_table(table_id: int) Table[source]

Retrieve a table instance based on its ID.

Parameters:

table_id (int) – The unique identifier of the table.

Returns:

An instance of the Table class.

Return type:

Table

make_api_request(endpoint: str, method: str = 'GET', data: Dict | None = None, headers: Dict[str, str] | None = None, timeout: int = 10, files: Dict[str, IO[bytes]] | None = None) Any[source]

Make an API request to the specified endpoint.

Parameters:
  • endpoint (str) – The API endpoint to make the request to.

  • method (str) – The HTTP method to use, by default “GET”.

  • data (dict, optional) – The data payload to send with the request, by default None.

  • headers (dict, optional) – Additional headers to send with the request, by default None.

  • timeout (int) – The maximum number of seconds to wait for the server response, by default 10.

  • files (dict, optional) – Files to be sent with the request, by default None.

Returns:

The parsed response data.

Return type:

Any

Raises:

BaserowHTTPError – If the response status code is in the defined ERROR_MESSAGES.

parse_response(response: Response, method: str, url: str) int | Dict[str, Any] | str | None[source]

Parses the response received from an HTTP request.

If the response has a status code of 204, it will return the status code. If the response body is empty and the method is not “DELETE” or the status code is not 204, a warning is logged. If the response body contains JSON, it attempts to parse and return the JSON. Otherwise, the raw response text is returned.

Parameters:
  • response (requests.Response) – The response object received from an HTTP request.

  • method (str) – The HTTP method that was used for the request.

  • url (str) – The complete URL the request was made to.

Returns:

Either the status code, a dictionary parsed from the JSON response, or the raw response text.

Return type:

Union[int, dict, str, None]

Raises:

ValueError – If the response cannot be parsed as JSON.

perform_request(method: str, url: str, headers: Dict[str, str], data: Dict | None = None, timeout: int = 10, files: Dict[str, str | IO[bytes]] | None = None) Response[source]

Performs an HTTP request using the given parameters.

Parameters:
  • method (str) – The HTTP method to use (e.g., “GET”, “POST”).

  • url (str) – The complete URL to make the request to.

  • headers (dict) – Headers to send with the request.

  • data (dict, optional) – The data payload to send with the request.

  • timeout (int) – The maximum number of seconds to wait for the server response.

  • files (dict, optional) – The files to send with the request, if any. The dictionary keys are the form field names, and the values are the file data.

Returns:

The server’s response to the request.

Return type:

requests.Response

Raises:
  • requests.exceptions.HTTPError – If the response status code is in the defined ERROR_MESSAGES.

  • requests.exceptions.Timeout – If the request times out.

  • requests.exceptions.RequestException – For other request-related exceptions like connectivity issues.

  • Exception – For any other unexpected exceptions.

Table

class baserowapi.models.table.Table(table_id: int, client: Baserow)[source]

Bases: object

Represents a table in Baserow with functionalities to manipulate and query rows, fields, etc.

FIELD_TYPE_CLASS_MAP: Dict[str, type] = {'boolean': <class 'baserowapi.models.fields.boolean_field.BooleanField'>, 'count': <class 'baserowapi.models.fields.count_field.CountField'>, 'created_on': <class 'baserowapi.models.fields.created_on_field.CreatedOnField'>, 'date': <class 'baserowapi.models.fields.date_field.DateField'>, 'email': <class 'baserowapi.models.fields.email_field.EmailField'>, 'file': <class 'baserowapi.models.fields.file_field.FileField'>, 'formula': <class 'baserowapi.models.fields.formula_field.FormulaField'>, 'generic': <class 'baserowapi.models.fields.generic_field.GenericField'>, 'last_modified': <class 'baserowapi.models.fields.last_modified_field.LastModifiedField'>, 'link_row': <class 'baserowapi.models.fields.table_link_field.TableLinkField'>, 'long_text': <class 'baserowapi.models.fields.long_text_field.LongTextField'>, 'lookup': <class 'baserowapi.models.fields.lookup_field.LookupField'>, 'multiple_collaborators': <class 'baserowapi.models.fields.multiple_collaborators_field.MultipleCollaboratorsField'>, 'multiple_select': <class 'baserowapi.models.fields.multiple_select_field.MultipleSelectField'>, 'number': <class 'baserowapi.models.fields.number_field.NumberField'>, 'password': <class 'baserowapi.models.fields.password_field.PasswordField'>, 'phone_number': <class 'baserowapi.models.fields.phone_number_field.PhoneNumberField'>, 'rating': <class 'baserowapi.models.fields.rating_field.RatingField'>, 'single_select': <class 'baserowapi.models.fields.single_select_field.SingleSelectField'>, 'text': <class 'baserowapi.models.fields.text_field.TextField'>, 'url': <class 'baserowapi.models.fields.url_field.UrlField'>}
add_rows(rows_data: Dict[str, Any] | List[Dict[str, Any]], batch_size: int | None = None) Row | List[Row][source]

Add a new row (or multiple rows) to the table.

Parameters:
  • rows_data (dict or list[dict]) – A dictionary representing the fields and values of the row to add, or a list of dictionaries for adding multiple rows.

  • batch_size (int) – The number of rows to include in each batch request when adding multiple rows. Defaults to the client’s batch_size.

Returns:

An instance of the Row model representing the added row or a list of Row instances for multiple rows.

Return type:

Row or list[Row]

Raises:
  • ValueError – If parameters are not valid.

  • Exception – If there’s any error during the API request.

delete_rows(rows_data: List[Row | int] | Generator[Row | int, None, None], batch_size: int | None = None) bool[source]

Deletes multiple rows from the table using the Baserow batch-delete endpoint.

This method accepts a list or generator of Row objects or integers. For each item: - If it’s a Row object, the method extracts its ID for deletion. - If it’s an integer, it represents the ID of the row to be deleted.

Parameters:
  • rows_data (list[Union[Row, int]] or Generator[Union[Row, int], None, None]) – A list or generator of Row objects or integers. Row objects represent the rows to be deleted, while integers represent the row IDs to be deleted.

  • batch_size (int, optional) – The number of rows to include in each batch request when deleting multiple rows. Defaults to None, in which case the client’s batch_size will be used.

Returns:

True if rows are successfully deleted, otherwise an exception is raised.

Return type:

bool

Raises:
  • ValueError – If parameters are not valid.

  • TypeError – If an item in rows_data is neither an integer nor a Row object.

  • Exception – If the API request results in any error responses.

property field_names: List[str]

Retrieve the names of all fields in the table, sorted by field.order.

Returns:

A list of field names.

Return type:

List[str]

Raises:

Exception – If there’s an error while fetching the field names.

property fields: FieldList

Retrieve the fields associated with the table.

If the fields haven’t been fetched yet, this property sends an API request to retrieve them. Once retrieved, the fields are cached to avoid unnecessary API requests in subsequent calls.

Returns:

A FieldList containing all the Field objects associated with this table.

Return type:

FieldList

Raises:

Exception – If there’s an unexpected error when fetching the fields.

get_row(row_id: int | str) Row[source]

Retrieve a specific row by its ID from the table.

Parameters:

row_id (int or str) – The unique identifier of the row to retrieve. This can be either an integer or a string that can be converted to an integer.

Returns:

An instance of the Row model representing the fetched row.

Return type:

Row

Raises:
  • ValueError – If the provided row_id is not valid or cannot be converted to an integer.

  • RowFetchError – If there’s any error during the API request or if the row is not found.

get_rows(include: List[str] | None = None, exclude: List[str] | None = None, search: str | None = None, order_by: List[str] | None = None, filter_type: str | None = None, filters: List[Filter] | None = None, view_id: int | None = None, size: int | None = None, limit: int | None = None, iterator: bool = False, **kwargs: Any) List[Row] | Generator[Row, None, None][source]

Retrieves rows from the table using provided parameters, with an optional limit on the number of rows.

Parameters:
  • include (list[str], optional) – A list of field names to include in the results.

  • exclude (list[str], optional) – A list of field names to exclude from the results.

  • search (str, optional) – A search string to apply on the table data.

  • order_by (list[str], optional) – Field by which the results should be ordered.

  • filter_type (str, optional) – The type of filter to be applied.

  • filters (list[Filter], optional) – A list containing Filter objects to be applied.

  • view_id (int, optional) – ID of the view to consider its filters and sorts.

  • size (int, optional) – The number of rows per page in the response.

  • limit (int, optional) – The maximum number of rows to return.

  • iterator (bool, optional) – If True, returns a generator of Row objects. If False, returns a list of Row objects.

  • kwargs (dict) – Additional parameters for the API request.

Returns:

A list or generator of Row objects, depending on the iterator parameter.

Return type:

Union[List[Row], Generator[Row, None, None]]

Raises:
  • Exception – If any error occurs during the process.

  • ValueError – If parameters are not valid.

property primary_field: str

Retrieve the primary field of the table.

If the primary field hasn’t been determined yet, this property will invoke the method to set it. Once set, the primary field is cached to avoid unnecessary computations in subsequent calls.

Returns:

The primary field of the table.

Return type:

str

row_generator(include: List[str] | None = None, exclude: List[str] | None = None, search: str | None = None, order_by: List[str] | None = None, filter_type: str | None = None, filters: List[Filter] | None = None, view_id: int | None = None, size: int | None = None, limit: int | None = None, **kwargs: Any) Generator[Row, None, None][source]

Generator function to retrieve rows from the table in a paginated manner, optionally limiting the number of rows returned.

Parameters:
  • include (list[str], optional) – A list of field names to include in the results.

  • exclude (list[str], optional) – A list of field names to exclude from the results.

  • search (str, optional) – A search string to apply on the table data.

  • order_by (list[str], optional) – Field by which the results should be ordered.

  • filter_type (str, optional) – The type of filter to be applied.

  • filters (list[Filter], optional) – A list containing Filter objects to be applied.

  • view_id (int, optional) – ID of the view to consider its filters and sorts.

  • size (int, optional) – The number of rows per page in the response.

  • limit (int, optional) – The maximum number of rows to return.

  • kwargs (dict) – Additional parameters for the API request.

Yield:

Yields Row objects as they are fetched, up to the specified limit.

Return type:

Generator[Row, None, None]

Raises:
  • RowFetchError – If any error occurs during the process.

  • ValueError – If parameters are not valid.

update_rows(rows_data: List[Dict[str, Any] | Row] | Generator[Row, None, None], batch_size: int | None = None) List[Row][source]

Updates multiple rows in the table using the Baserow batch update endpoint.

Parameters:
  • rows_data (list[Union[dict, Row]]) – A list of dictionaries or Row objects. Each dictionary should contain the field values for updating a specific row and include the ID of the row to be updated. Row objects represent the rows to be updated.

  • batch_size (int) – The number of rows to process in each batch.

Returns:

A list of Row objects representing the updated rows.

Return type:

list[Row]

Raises:
  • ValueError – If parameters are not valid.

  • KeyError – If a dictionary contains a key that doesn’t correspond to any writable field in the table or is missing the ‘id’ key.

  • TypeError – If an item in rows_data is neither a dictionary nor a Row object, or if a generator is passed.

  • Exception – If the API request results in any error responses.

property writable_fields: FieldList

Retrieve the list of writable fields for the table.

This property lazily loads the fields using the fields property and then filters them to include only those fields where is_read_only is False.

Returns:

A FieldList containing only writable Field objects.

Return type:

FieldList

Fields

class baserowapi.models.fields.BooleanField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a boolean field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘boolean’.

TYPE = 'boolean'
property compatible_filters: List[str]

Get the list of compatible filters for this BooleanField.

Returns:

The list of compatible filters.

Return type:

List[str]

validate_value(value: bool) None[source]

Validate the value for a BooleanField.

Parameters:

value (bool) – The boolean value to be validated.

Raises:

FieldValidationError – If the value is not of boolean type.

class baserowapi.models.fields.CountField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a field connected to a link to table field which returns the number of relations.

Variables:

TYPE (str) – The type of the field, which is ‘count’.

TYPE = 'count'
property compatible_filters: List[str]

Get the list of compatible filters for this CountField.

Returns:

The list of compatible filters.

Return type:

List[str]

property is_read_only: bool

Determine if the field is read-only.

Returns:

Always True for CountField.

Return type:

bool

property table_id: int | None

Retrieve the table_id of the field from field_data.

Returns:

The table_id of the field.

Return type:

Optional[int]

property through_field_id: str | None

Retrieve the through_field_id of the field from field_data.

Returns:

The id of the linking field.

Return type:

Optional[str]

class baserowapi.models.fields.CreatedOnField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: BaseDateField

Represents a field in Baserow that indicates the creation date.

Variables:

TYPE (str) – The type of the field, which is ‘created_on’.

TYPE = 'created_on'
property compatible_filters: List[str]

Get the list of compatible filters for this CreatedOnField.

Returns:

The list of compatible filters.

Return type:

List[str]

property is_read_only: bool

Determine if the CreatedOnField is read-only.

Returns:

True, as this field type is always read-only.

Return type:

bool

class baserowapi.models.fields.DateField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: BaseDateField

Represents a date-only field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘date’.

TYPE = 'date'
property compatible_filters: List[str]

Get the list of compatible filters for this DateField.

Returns:

The list of compatible filters.

Return type:

List[str]

class baserowapi.models.fields.EmailField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: BaseTextClass

Represents an email field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘email’.

TYPE = 'email'
property compatible_filters: List[str]

Get the list of compatible filters for this EmailField.

Returns:

The list of compatible filters.

Return type:

List[str]

class baserowapi.models.fields.FieldList(fields: List[Field])[source]

Bases: object

Represents a list of Field objects.

Variables:
  • fields (List[Field]) – A list containing the Field objects.

  • logger (logging.Logger) – A logger instance for the class.

class baserowapi.models.fields.FileField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a field in Baserow that handles file data.

Variables:

TYPE (str) – The type of the field, which is ‘file’.

TYPE = 'file'
property compatible_filters: List[str]

Get the list of compatible filters for this FileField.

Returns:

The list of compatible filters.

Return type:

List[str]

validate_value(value: List[Dict[str, Any]]) None[source]

Validates the value for a FileField.

Parameters:

value (List[Dict[str, Any]]) – A list of file objects to validate.

Raises:

FieldValidationError – If the value is not a list or if a file object is missing the ‘name’ attribute.

class baserowapi.models.fields.FormulaField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a field that computes its value based on a formula.

Variables:

TYPE (str) – The type of the field, which is ‘formula’.

TYPE = 'formula'
property array_formula_type: str | None

Retrieve the array formula type of the field.

Returns:

The array formula type of the field.

Return type:

Optional[str]

property compatible_filters: List[str]

Get the list of compatible filters for this FormulaField.

Returns:

The list of compatible filters.

Return type:

List[str]

property error: str | None

Retrieve the error (if any) associated with the formula.

Returns:

The error associated with the formula.

Return type:

Optional[str]

property formula: str | None

Retrieve the formula of the field.

Returns:

The formula of the field.

Return type:

Optional[str]

property formula_type: str | None

Retrieve the formula type of the field.

Returns:

The formula type of the field.

Return type:

Optional[str]

property is_read_only: bool

Determine if the field is read-only.

Returns:

Always returns True for a FormulaField.

Return type:

bool

class baserowapi.models.fields.GenericField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a generic field for unknown or unsupported field types in Baserow.

TYPE = 'generic'
property compatible_filters: List[str]
validate_value(value: Any) None[source]

Validate the value against the field’s criteria.

Child classes can override for custom rules.

Parameters:

value (Any) – The value to be validated.

class baserowapi.models.fields.LastModifiedField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: BaseDateField

Represents a field in Baserow that indicates the last modified date.

Variables:

TYPE (str) – The type of the field, which is ‘last_modified’.

TYPE = 'last_modified'
property compatible_filters: List[str]

Get the list of compatible filters for this LastModifiedField.

Returns:

The list of compatible filters.

Return type:

List[str]

property is_read_only: bool

Determine if the LastModifiedField is read-only.

Returns:

True, as this field type is always read-only.

Return type:

bool

class baserowapi.models.fields.LongTextField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: BaseTextClass

Represents a long text field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘long_text’.

TYPE = 'long_text'
property compatible_filters: List[str]

Get the list of compatible filters for this LongTextField.

Returns:

The list of compatible filters.

Return type:

List[str]

property long_text_enable_rich_text: bool

Get the rich text enable status for this LongTextField.

Returns:

The rich text enable status.

Return type:

bool

property text_default: str

Get the default text value for this LongTextField.

Returns:

The default text value.

Return type:

str

class baserowapi.models.fields.LookupField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a field connected to a link to table field which returns an array of values and row ids from the chosen lookup field in the linked table.

Variables:

TYPE (str) – The type of the field, which is ‘lookup’.

TYPE = 'lookup'
property compatible_filters: List[str]

Get the list of compatible filters for this LookupField.

Returns:

The list of compatible filters.

Return type:

List[str]

property target_field_id: int | None

Retrieve the target_field_id of the field from field_data.

Returns:

The id of the target field.

Return type:

Optional[int]

property target_field_name: str | None

Retrieve the target_field_name of the field from field_data.

Returns:

The name of the target field.

Return type:

Optional[str]

property through_field_id: int | None

Retrieve the through_field_id of the field from field_data.

Returns:

The id of the linking field.

Return type:

Optional[int]

property through_field_name: int | None

Retrieve the through_field_name of the field from field_data.

Returns:

The name of the linking field.

Return type:

Optional[int]

class baserowapi.models.fields.MultipleCollaboratorsField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a list of Baserow collaborators.

Variables:

TYPE (str) – The type of the field, which is ‘multiple_collaborators’.

TYPE = 'multiple_collaborators'
property compatible_filters: List[str]

Get the list of compatible filters for this MultipleCollaboratorsField.

Returns:

The list of compatible filters.

Return type:

List[str]

property notify_user_when_added: bool

Determine if the user should be notified when added.

Returns:

True if the user should be notified, False otherwise.

Return type:

bool

validate_value(value: List[Dict[str, Any]]) None[source]

Validate the value for a MultipleCollaboratorsField.

Parameters:

value (List[Dict[str, Any]]) – A list of dictionaries representing collaborator data.

Raises:

FieldValidationError – If the provided value is not a list or if the format is incorrect.

class baserowapi.models.fields.MultipleSelectField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a multiple-select field allowing the user to select multiple options from a predefined set of options.

Variables:

TYPE (str) – The type of the field, which is ‘multiple_select’.

TYPE = 'multiple_select'
property compatible_filters: List[str]

Get the list of compatible filters for this MultipleSelectField.

Returns:

The list of compatible filters.

Return type:

List[str]

format_for_api(values: List[Dict[str, Any] | int | str]) List[str | int][source]

Formats the multiple select values for API submission.

Parameters:

values (List[Union[Dict[str, Any], int, str]]) – The list of values to format. Can include dictionaries (from raw_value), IDs, or strings.

Returns:

A list of IDs or value strings to be submitted to the API.

Return type:

List[Union[int, str]]

Raises:

FieldValidationError – If any value in the list is not valid.

property options: List[str]

Retrieve a list of select option values from the field_data.

Returns:

List of select option values.

Return type:

List[str]

property options_details: List[Dict[str, Any]]

Retrieve a list including details like id, value, color of each select_option.

Returns:

List of detailed select_options.

Return type:

List[Dict[str, Any]]

validate_value(values: List[str | int]) None[source]

Validates the values for a MultipleSelectField.

Parameters:

values (List[Union[int, str]]) – The list of values to validate.

Raises:

FieldValidationError – If the provided values list contains a value that doesn’t match any select option.

class baserowapi.models.fields.NumberField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a number field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘number’.

TYPE = 'number'
property allow_negative: bool

Determine if the NumberField allows negative numbers.

Returns:

True if negative numbers are allowed, else False.

Return type:

bool

property compatible_filters: List[str]

Get the list of compatible filters for this NumberField.

Returns:

The list of compatible filters.

Return type:

List[str]

property decimal_places: int

Get the number of decimal places allowed for this NumberField.

Returns:

The number of decimal places.

Return type:

int

validate_value(value: int | float | str) None[source]

Validate the value for a NumberField.

Parameters:

value (Union[int, float, str]) – The number value to be validated.

Raises:

FieldValidationError – If the value doesn’t match the expected type or constraints.

class baserowapi.models.fields.PasswordField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a password field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘password’.

TYPE = 'password'
validate_value(value: Any) None[source]

Validate the value for a PasswordField. Ensure it’s a string, None, or True.

Parameters:

value (Any) – The value to be validated.

Raises:

FieldValidationError – If the value is not a string, None, or True.

class baserowapi.models.fields.PhoneNumberField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a phone number field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘phone_number’.

TYPE = 'phone_number'
property compatible_filters: List[str]

Get the list of compatible filters for this PhoneNumberField.

Returns:

The list of compatible filters.

Return type:

List[str]

validate_value(value: str) None[source]

Validate the value for a PhoneNumberField.

Phone numbers can have a maximum length of 100 characters consisting solely of digits, spaces, and the characters: Nx,._+*()#=;/-.

Parameters:

value (str) – The phone number string to be validated.

Raises:

FieldValidationError – If the phone number doesn’t match the expected format.

class baserowapi.models.fields.RatingField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a rating field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘rating’.

TYPE = 'rating'
property compatible_filters: List[str]

Get the list of compatible filters for this RatingField.

Returns:

The list of compatible filters.

Return type:

List[str]

validate_value(value: int) None[source]

Validate the value for a RatingField.

Parameters:

value (int) – The rating value to be validated.

Raises:

FieldValidationError – If the value doesn’t match the expected type or constraints.

class baserowapi.models.fields.SingleSelectField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: Field

Represents a single select field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘single_select’.

TYPE = 'single_select'
property compatible_filters: List[str]

Get the list of compatible filters for this SingleSelectField.

Returns:

The list of compatible filters.

Return type:

List[str]

format_for_api(value: dict | int | str) int | str[source]

Formats the single select value for API submission.

Parameters:

value (Union[dict, int, str]) – The value to format (can be an option dictionary, ID, or string).

Returns:

The ID or value string to be submitted to the API.

Return type:

Union[int, str]

Raises:

FieldValidationError – If the value is not valid.

property options: List[str]

Retrieve a list of select option values from the field_data.

Returns:

List of select option values.

Return type:

List[str]

property options_details: List[Dict[str, Any]]

Retrieve a list including details like id, value, color of each select_option.

Returns:

List of detailed select_options.

Return type:

List[Dict[str, Any]]

validate_value(value: int | str) None[source]

Validates the value for a SingleSelectField.

Parameters:

value (Union[int, str]) – The value to validate.

Raises:

FieldValidationError – If the provided value doesn’t match any select option.

class baserowapi.models.fields.TableLinkField(name: str, field_data: Dict[str, Any], client: Any | None = None)[source]

Bases: Field

Represents a field that links to rows in another table.

Variables:

TYPE (str) – The type of the field, which is ‘link_row’.

TYPE = 'link_row'
property compatible_filters: List[str]

Get the list of compatible filters for this TableLinkField.

Returns:

The list of compatible filters.

Return type:

List[str]

format_for_api(value: int | str | List[str | int]) List[str | int][source]

Format the value for API submission. This method normalizes and validates the input value, returning a list of IDs or values suitable for API submission.

Parameters:

value (Union[int, str, List[Union[int, str]]]) – A single ID, a comma-separated string of names, or a list of IDs/values.

Returns:

A list of IDs or values suitable for API submission.

Return type:

List[Union[int, str]]

Raises:

FieldValidationError – If the provided value is not in an expected format.

get_options() List[str][source]

Fetches and returns the primary values from the related table that are possible for the TableLinkRowValue.

This method retrieves the rows from the related table and extracts the primary field values from each row.

Returns:

A list of primary field values from the related table.

Return type:

List[str]

Raises:

FieldDataRetrievalError – If there’s an error fetching the primary values from the related table.

property link_row_limit_selection_view_id: int | None

Retrieve the link_row_limit_selection_view_id of the field from field_data.

Returns:

The link_row_limit_selection_view_id of the field.

Return type:

Optional[int]

property link_row_related_field_id: int | None

Retrieve the link_row_related_field_id of the field from field_data.

Returns:

The link_row_related_field_id of the field.

Return type:

Optional[int]

property link_row_table_id: int | None

Retrieve the link_row_table_id of the field from field_data.

Returns:

The link_row_table_id of the field.

Return type:

Optional[int]

validate_value(value: int | str | List[str | int]) None[source]

Validate the value for the TableLinkField. Ensure it’s a list of integers or strings, or a single integer or string that can be converted to a list.

This method checks whether the provided value is valid according to the rules defined for the TableLinkField. If the value is not valid, it raises a FieldValidationError.

Parameters:

value (Union[int, str, List[Union[int, str]]]) – The value to be validated. It can be an integer, a string, or a list of these.

Raises:

FieldValidationError – If the value is not in the expected format.

class baserowapi.models.fields.TextField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: BaseTextClass

Represents a text field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘text’.

TYPE = 'text'
property compatible_filters: List[str]

Get the list of compatible filters for this TextField.

Returns:

The list of compatible filters.

Return type:

List[str]

property text_default: str

Get the default text value for this TextField.

Returns:

The default text value.

Return type:

str

class baserowapi.models.fields.UrlField(name: str, field_data: Dict[str, Any], client=None)[source]

Bases: BaseTextClass

Represents a URL field in Baserow.

Variables:

TYPE (str) – The type of the field, which is ‘url’.

TYPE = 'url'
property compatible_filters: List[str]

Get the list of compatible filters for this UrlField.

Returns:

The list of compatible filters.

Return type:

List[str]

Row

class baserowapi.models.row.Row(row_data: Dict[str, Any], table: Table, client: Client)[source]

Bases: object

Represents a row in a Baserow table. Provides methods to update, delete, and manipulate the row.

delete() bool[source]

Deletes the row from the table using the Baserow delete endpoint.

Returns:

True if deletion was successful.

Return type:

bool

Raises:

RowDeleteError – For errors during the delete operation.

property fields: List[str]

Lazily retrieves a list of all field names from the Row’s values.

Returns:

A list of field names.

Return type:

List[str]

logger: Logger = <Logger baserowapi.models.row (WARNING)>
move(before_id: int | None = None) Row[source]

Moves the current row to a position before the row specified by before_id.

Parameters:

before_id (int, optional) – The ID of the row before which the current row should be moved. If not specified, the row will be moved to the last position.

Returns:

A Row object representing the updated row.

Return type:

Row

Raises:

RowMoveError – If there’s an error during the move operation.

to_dict() Dict[str, Any][source]

Converts the Row’s values to a dictionary.

Returns:

A dictionary representation of the row’s values.

Return type:

dict[str, Any]

update(values: Dict[str, Any] | None = None, memory_only: bool = False) Row[source]

Updates the row in the table and synchronizes the internal state.

Parameters:
  • values (dict[str, Any], optional) – A dictionary containing field values for updating the row. Defaults to values from the self.values property.

  • memory_only (bool, optional) – If True, only updates the in-memory row and skips the API request. Defaults to False.

Returns:

A Row object representing the updated row.

Return type:

Row

Raises:

RowUpdateError – If the API request results in any error responses.

property values: RowValueList

Retrieves the RowValueList for this row. If not yet created, it lazily loads the list using the stored row data and synchronizes the internal state.

Returns:

RowValueList representing the values for this row.

Return type:

RowValueList

Raises:

RowFetchError – If there’s an error creating the RowValueList.

RowValue

class baserowapi.models.row_values.BooleanRowValue(field: BooleanField, raw_value: bool | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically designed for a BooleanField.

field

The associated BooleanField object.

Type:

BooleanField

raw_value

The raw boolean value as fetched/returned from the API.

Type:

Optional[bool]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

property value: bool | None

Get the value in a user-friendly format. For BooleanRowValue, this returns the raw value as a boolean or None.

Returns:

The boolean value of the raw_value or None.

class baserowapi.models.row_values.CountRowValue(field: CountField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue designed for a CountField.

Parameters:
  • field – The associated CountField object.

  • raw_value – The raw value as fetched/returned from the API, representing the main (primary) field text values of the linked rows. Defaults to None.

  • client – The Baserow class API client. Some RowValue subclasses might need this. Defaults to None.

Raises:

InvalidRowValueError – If the provided field is not an instance of the CountField class.

property value: Any

Get the value in a user-friendly format. This method returns the main (primary) field text values of the linked rows.

Returns:

The main (primary) field text values of the linked rows.

Return type:

Any

class baserowapi.models.row_values.CreatedOnRowValue(field: CreatedOnField, raw_value: str | None = None, client: Any | None = None)[source]

Bases: BaseDateRowValue

Represents a RowValue specifically designed for a CreatedOnField.

field

The associated CreatedOnField object.

Type:

CreatedOnField

raw_value

The raw date value as fetched/returned from the API, typically in ISO format.

Type:

Optional[str]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

property value: str | None

Get the value in ISO format.

Returns:

The value in ISO format, or None if no value is set.

class baserowapi.models.row_values.DateRowValue(field: DateField, raw_value: str | None = None, client: Any | None = None)[source]

Bases: BaseDateRowValue

Represents a RowValue specifically designed for a DateField.

field

The associated DateField object.

Type:

DateField

raw_value

The raw date value as fetched/returned from the API, typically in ISO format.

Type:

Optional[str]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

class baserowapi.models.row_values.EmailRowValue(field: EmailField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically designed for an EmailField.

field

The associated EmailField object.

Type:

EmailField

raw_value

The raw value as fetched/returned from the API.

Type:

Optional[Any]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

class baserowapi.models.row_values.FileRowValue(field: FileField, client: Any, raw_value: List[Any] | None = None)[source]

Bases: RowValue

Represents a RowValue designed for a FileField.

Parameters:
  • field – The associated FileField object.

  • client – The Baserow class API client to make API requests.

  • raw_value – The raw value as fetched/returned from the API. Defaults to None.

Raises:

InvalidRowValueError – If the provided field is not an instance of the FileField class.

download_files(directory_path: str) List[str][source]

Downloads all file objects in the FileRowValue to the specified directory.

Parameters:

directory_path – The path to the directory where the files should be downloaded.

Returns:

List of filenames that were successfully downloaded.

Raises:

RowValueOperationError – If there’s an error during the download process.

upload_file_to_server(file_path: str | None = None, url: str | None = None, replace: bool = False) List[Any][source]

Upload a file or files to Baserow either from a local path or by downloading it from a provided URL. The method either appends or replaces the current value based on the ‘replace’ flag.

Note: This function updates the in-memory representation of the row value. Use row.update() to save the updated value to the server.

Parameters:
  • file_path – Path to the file or directory to be uploaded. Defaults to None.

  • url – The URL of the file to download and upload. Defaults to None.

  • replace – If True, replaces the current value with the uploaded file’s data. Otherwise, appends. Defaults to False.

Returns:

A list of file object representations returned by Baserow.

Raises:
  • InvalidRowValueError – If neither file_path nor url is provided.

  • RowValueOperationError – If there’s an error during the upload process.

class baserowapi.models.row_values.FormulaRowValue(field: FormulaField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue designed for a FormulaField.

Parameters:
  • field – The associated FormulaField object.

  • raw_value – The raw value as fetched/returned from the API. Defaults to None.

  • client – The Baserow class API client. Some RowValue subclasses might need this. Defaults to None.

Raises:

InvalidRowValueError – If the provided field is not an instance of the FormulaField class.

property value: Any

Get the value in a user-friendly format. This method returns the raw value.

Returns:

The raw value of the FormulaRowValue.

Return type:

Any

class baserowapi.models.row_values.GenericRowValue(field: GenericField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue for an unsupported or generic field type.

Parameters:
  • field – The associated GenericField object.

  • raw_value – The raw value as fetched/returned from the API. Defaults to None.

  • client – The Baserow class API client. Defaults to None.

Raises:

InvalidRowValueError – If the provided field is not an instance of the GenericField class.

property value: Any

Retrieve the value of the GenericRowValue.

Returns:

The raw value.

class baserowapi.models.row_values.LastModifiedRowValue(field: LastModifiedField, raw_value: str | None = None, client: Any | None = None)[source]

Bases: BaseDateRowValue

Represents a RowValue specifically designed for a LastModifiedField.

field

The associated LastModifiedField object.

Type:

LastModifiedField

raw_value

The raw date value as fetched/returned from the API, typically in ISO format.

Type:

Optional[str]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

property value: str | None

Get the value in ISO format.

Returns:

The value in ISO format, or None if no value is set.

class baserowapi.models.row_values.LongTextRowValue(field: LongTextField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically for a LongTextField.

field

The associated LongTextField object.

Type:

LongTextField

raw_value

The raw value as returned/fetched from the API.

Type:

Optional[Any]

client

The Baserow class API client. Some RowValue subclasses may need access to the API.

Type:

Optional[Any]

class baserowapi.models.row_values.LookupRowValue(field: LookupField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue designed for a LookupField.

Parameters:
  • field – The associated LookupField object.

  • raw_value – The raw value as fetched/returned from the API, representing an array of values and row IDs. Defaults to None.

  • client – The Baserow class API client. Some RowValue subclasses might need this. Defaults to None.

Raises:

InvalidRowValueError – If the provided field is not an instance of the LookupField class.

property value: List[str | int]

Get the value in a user-friendly format. This method returns a list of primary field values or IDs.

Returns:

A list of primary field values or IDs.

Return type:

List[Union[int, str]]

class baserowapi.models.row_values.MultipleCollaboratorsRowValue(field: MultipleCollaboratorsField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue designed for a MultipleCollaboratorsField.

Parameters:
  • field – The associated MultipleCollaboratorsField object.

  • raw_value – The raw value as fetched/returned from the API. Defaults to None.

  • client – The Baserow class API client. Some RowValue subclasses might need this. Defaults to None.

Raises:

InvalidRowValueError – If the provided field is not an instance of the MultipleCollaboratorsField class.

property value: Any

Get the value in a user-friendly format. This method returns the raw value.

Returns:

The raw value.

Return type:

Any

class baserowapi.models.row_values.MultipleSelectRowValue(field: MultipleSelectField, raw_value: List[Any | None] = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue designed for a MultipleSelectField.

Parameters:
  • field – The associated MultipleSelectField object.

  • raw_value – The raw values as fetched/returned from the API. Defaults to None.

  • client – The Baserow class API client. Some RowValue subclasses might need this. Defaults to None.

Raises:

InvalidRowValueError – If the provided field is not an instance of the MultipleSelectField class.

property options: List[str]

Get a list of available option values for the associated MultipleSelectField.

Returns:

A list of available option values.

Return type:

List[str]

Raises:

RowValueOperationError – If the associated field does not have the “options” attribute.

property value: List[str]

Get the values in a user-friendly format. This method returns a list of option names.

Returns:

A list of the selected option names.

Return type:

List[str]

class baserowapi.models.row_values.NumberRowValue(field: NumberField, raw_value: str | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically designed for a NumberField.

field

The associated NumberField object.

Type:

NumberField

raw_value

The raw numeric value as fetched/returned from the API.

Type:

Optional[str]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

property value: str

Get the value in a user-friendly format. For NumberRowValue, this returns the raw value as a string.

Returns:

The raw value as a string.

class baserowapi.models.row_values.PasswordRowValue(field: Field, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a row value for a password field.

Parameters:
  • field – The associated Field object.

  • raw_value – The raw value as fetched/returned from the API. Defaults to None.

  • client – The Baserow class API client. Defaults to None.

Raises:

InvalidRowValueError – If the new value is not valid as per the associated Field’s validation.

property value: bool

Retrieve the value indicating whether the password is set.

Returns:

True if the password is set, otherwise False.

class baserowapi.models.row_values.PhoneNumberRowValue(field: PhoneNumberField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically designed for a PhoneNumberField.

field

The associated PhoneNumberField object.

Type:

PhoneNumberField

raw_value

The raw value as fetched/returned from the API.

Type:

Optional[Any]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

property value: Any

Get the value in a user-friendly format.

Returns:

The raw value.

class baserowapi.models.row_values.RatingRowValue(field: RatingField, raw_value: int | float | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically designed for a RatingField.

field

The associated RatingField object.

Type:

RatingField

raw_value

The raw numerical value as fetched/returned from the API.

Type:

Optional[Union[int, float]]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

property value: int | float

Get the value in a user-friendly format. For RatingRowValue, this returns the raw value directly as it’s already user-friendly.

Returns:

The numerical value.

class baserowapi.models.row_values.RowValueList(row_values: List[RowValue] | None = None)[source]

Bases: object

A list-like container for RowValue objects.

Variables:

row_values (List[RowValue]) – A list of RowValue objects.

add(row_value: RowValue) None[source]

Add a RowValue object to the list.

Parameters:

row_value (RowValue) – The RowValue object to be added.

Raises:

TypeError – If the provided object is not an instance of RowValue.

property fields: List[str]

Lazy-loaded property that returns a list of all field names for the RowValues in the list.

Returns:

A list of field names.

Return type:

List[str]

class baserowapi.models.row_values.SingleSelectRowValue(field: SingleSelectField, raw_value: dict | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically designed for a SingleSelectField.

field

The associated SingleSelectField object.

Type:

SingleSelectField

raw_value

The raw value as fetched/returned from the API.

Type:

Optional[dict]

client

The Baserow class API client. Some RowValue subclasses may require access to the API.

Type:

Optional[Any]

property options: List[str]

Get a list of available option values for the associated SingleSelectField.

Returns:

A list of available option values.

Return type:

List[str]

Raises:

AttributeError – If the associated field does not have the “options” attribute.

property value: str

Get the value in a user-friendly format. For SingleSelectRowValue, this returns the option’s text or “None” if no option is selected.

Returns:

The selected option’s text or “None” if no option is selected.

class baserowapi.models.row_values.TableLinkRowValue(field: TableLinkField, raw_value: List[str | int] | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue designed for a TableLinkField.

Parameters:
  • field – The associated TableLinkField object.

  • raw_value – The raw value as fetched/returned from the API. Defaults to None.

  • client – The Baserow class API client. Some RowValue subclasses might need this. Defaults to None.

Raises:

InvalidRowValueError – If the provided field is not an instance of the TableLinkField class.

format_for_api() Any[source]

Format the value for API submission by delegating to the associated Field’s format_for_api method.

Returns:

Formatted value for API submission.

property value: List[str | int]

Get the value in a user-friendly format. This method returns a list of primary field values or IDs.

Returns:

A list of primary field values or IDs.

Return type:

List[Union[int, str]]

class baserowapi.models.row_values.TextRowValue(field: TextField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically for a TextField.

field

The associated TextField object.

Type:

TextField

raw_value

The raw value as returned/fetched from the API.

Type:

Optional[Any]

client

The Baserow class API client. Some RowValue subclasses may need access to the API.

Type:

Optional[Any]

class baserowapi.models.row_values.UrlRowValue(field: UrlField, raw_value: Any | None = None, client: Any | None = None)[source]

Bases: RowValue

Represents a RowValue specifically for a UrlField.

field

The associated UrlField object.

Type:

UrlField

raw_value

The raw value as returned/fetched from the API.

Type:

Optional[Any]

client

The Baserow class API client. Some RowValue subclasses may need access to the API.

Type:

Optional[Any]

Filter

class baserowapi.models.filter.Filter(field_name: str, value: str, operator: str = 'equal')[source]

Bases: object

Represents a filter expression used to filter results when fetching rows from a table.

Attributes: - field_name (str): The name of the field to apply the filter on. - value (str, int, etc.): The value to compare against using the operator. - operator (str): The comparison operator. Default is “equal”.

Properties: - query_string (str): Computes the API’s required GET parameter string.

property query_string: str

Returns the filter as a query string formatted for use as a GET parameter in an API call.

Format: filter__<encoded_field_name>__<operator>=<encoded_value>