Skip to content

Tables and Access Groups ​

Every record lives in a table, in one access group. There is no schema to set up: a table is created by its first record and goes away when its last record is deleted.

A table is always written as a dict with its name and its access group:

python
{"name": "posts", "access_group": "public"}

Table names are 1 to 256 characters long, with no control characters. /, !, *, # and % count as 3 characters each.

WARNING

Writing the table as a plain string, "table": "posts", is deprecated in get_records and delete_records. It still means the public records of that table and raises a DeprecationWarning once. Always write {"name", "access_group"}.

Access groups ​

access_groupSame asWho can read the records
"public"0Anyone, signed in or not.
"authorized"1Any signed-in user.
2 to 98Users whose own access group is that number or higher.
"admin"99Admins and the project owner.
"private""*"The uploader, and the users they grant access to.

A user reads records in access groups up to their own, which is the access_group in their profile (skapi.user["access_group"]). The project owner sets it on skapi.com. Records come back with "public", "authorized", "admin", "private" or the number.

One table can hold records in several access groups. A query reads one table in one access group at a time:

python
from skapi import Skapi, SkapiError

skapi = Skapi("<Project ID>")

public_notes = skapi.get_records({"table": {"name": "notes", "access_group": "public"}})
member_notes = skapi.get_records({"table": {"name": "notes", "access_group": "authorized"}})

Who can write ​

Signed-out callers can create records in "public" only, and must write "access_group": "public" (or 0). Otherwise:

They try tocodemessage
name another access groupINVALID_PARAMETERUnsigned users have no access to records with access group.
leave access_group outINVALID_REQUESTPublic users can only post records to public tables.
update a recordINVALID_REQUESTPublic users cannot update existing records.
set a unique_idINVALID_REQUESTPublic users cannot set unique_id for records.
remove filesINVALID_REQUESTPublic users cannot remove files from records.

They cannot delete records either: delete_records needs a signed-in user. A record they create has a user_id that starts with anonymous:. It is temporary and names no user.

Signed-in users can post records to any access group up to their own, and to "private". They can update and delete only their own records, and not read-only ones. Admins can delete any record.

Reading while signed out ​

A signed-out caller can read only "public" records. Naming any other access group raises INVALID_PARAMETER: Unsigned users have no access to records with access group.

Require Login ​

When the project's Require Login setting is on (in the project settings on skapi.com), get_records refuses signed-out callers before anything is sent:

python
try:
    skapi.get_records({"table": {"name": "posts", "access_group": "public"}})
except SkapiError as err:
    if err.code == "REQUIRE_LOGIN":
        print("Sign in first")

The message is This project requires users to sign in before reading its database, so "get_records" is not available to a signed-out visitor. Signed-in users are not affected, and neither are get_tables, get_tags, get_indexes and get_unique_id. The setting is a guard in the SDK, not an access rule on the server: data that must stay hidden from signed-out callers belongs in an access group above "public".

Next ​

skapi-py 2.4.0