Skip to content

Views

You'll find below all the available methods to interact with the views of a SeaTable table.

Examples assume authenticated base

All examples on this page assume that base has been initialized and authenticated as described on the introduction page. For the structure of objects returned by these methods, see the API model reference.

Get view(s)

get_view_by_name

Get a view of the table table_name, specified by its name view_name.

base.get_view_by_name(table_name, view_name)
Output Single view dict (throws an error if no view called view_name exists or if no table named table_name exists)

Example

view = base.get_view_by_name('Table1', 'Default View')
print(view)

list_views

Get all the views of the table named table_name.

base.list_views(table_name)

Output Dict with a single views key containing a list of the table's views (throws an error if no table named table_name exists)

Example

views = base.list_views('Table1')
print(views)

Add view

add_view

Add a view named view_name to the table table_name.

base.add_view(table_name, view_name)

Output Single view dict (throws an error if a view called view_name already exists or if no table named table_name exists)

Example

view = base.add_view('Table1', 'New view')
print(view)

Rename view

rename_view

Rename a view in the table table_name specified by its current name view_name and its new name new_view_name. Please ensure that no view named new_view_name already exists in the table table_name.

base.rename_view(table_name, view_name, new_view_name)

Output Single view dict (throws an error if no view called view_name exists or if no table named table_name exists)

Example

view = base.rename_view('Table1', 'MyView', 'NewView')
print(view)

Delete view

delete_view

Delete a view in the table table_name, specified by its name view_name. DO NOT try to delete the last view or you might no longer be able to access your table!

base.delete_view(table_name, view_name)

Output Dict containing a single success key with the result of the operation (throws an error if no table named table_name exists). Be careful, {'success':True} will be returned even if no view named view_name exists!

Example

print(base.delete_view('Table1', 'MyView'))