Skip to main content
Version: 12.2.0

viktor.api_v1

User

class viktor.api_v1.User(*, first_name, last_name, email, job_title)

User information

Parameters
  • first_name (str) – user’s first name

  • last_name (str) – user’s last name

  • email (str) – user’s email address

  • job_title (str) – user’s job title

property full_name

User’s full name (first name + last name).

Return type

str

EntityType

class viktor.api_v1.EntityType(name, id_)

Warning

Do not instantiate this class directly in an application. It is created by the API.

property name
Return type

str

classmethod from_json(json_)
Return type

EntityType

Entity

class viktor.api_v1.Entity(api, origin_id, operations=None, resolved=None)

Warning

Do not instantiate this class directly in an application. It is created by the API.

property name
Return type

str

property entity_type
Return type

EntityType

property id
Return type

int

property last_saved_params
Return type

Munch

property last_saved_summary
Return type

Munch

parent()
Return type

Entity

children(*, include_params=True, entity_type_names=None)
Return type

EntityList

siblings(*, include_params=True, entity_type_names=None)
Return type

EntityList

get_file()

Get the file of the entity.

Return type

File

Returns

File object (SourceType.URL)

Raises

ValueError – if file does not have a file associated with it.

EntityList

class viktor.api_v1.EntityList(api, relation, origin, entity_type_names, include_params)

Warning

Do not instantiate this class directly in an application. It is created by the API.

Object which resembles a list of Entity’s.

Most commonly used list operations are supported:

# indexing
children = entity.children()
children[0]  # first child entity
children[-1]  # last child entity

# length
number_of_children = len(children)

# for loop
for child in children:
    # perform operation on child

API

class viktor.api_v1.API

Starting point of making an API call to, for example, retrieve properties of a parent or child entity.

Note that the permissions of a user (group) are reflected on the permissions of this API call, e.g. if a user only has read-navigate or read-basic permission, calling the properties (read-all) of the object using this API will NOT work for this specific user.

Example:

current_entity = API().get_entity(entity_id)
parent = entity.parent()
parent_params = parent.last_saved_params
get_entity(id_)

Get the entity with given id.

Parameters

id – entity_id

Return type

Entity

get_root_entities(*, include_params=True, entity_type_names=None)

Get the root entities.

Parameters
  • include_params (bool) – True to include the parameters of the root entities.

  • entity_type_names (Optional[List[str]]) – Only filters the entities of the defined type(s) (default = None, returns all).

Return type

EntityList

get_entity_file(entity_id)

Get the file of the entity.

Parameters

entity_id (int) – id of the entity to get the file from.

Return type

File

Returns

File object (SourceType.URL)

Raises

ValueError – if file does not have a file associated with it.

get_current_user()
Return type

User

PrivilegedAPI

class viktor.api_v1.PrivilegedAPI

For making API calls that bypass the user access restrictions managed by the admin of an application.

Warning

If not used properly, (confidential) information which SHOULD NOT be accessible by a user may leak (for instance by including data in a view). Please consider the following when using this class:

  • Make sure the app’s admin is aware that the code circumvents certain permissions at specific places.

  • Make sure to test the implementation thoroughly, to ensure no confidential data is leaked.

Note

API calls can only bypass the restrictions if the key uses_privileged_api is set to true in the manifest. This is to provide an additional layer of security / awareness.

get_entity(id_)

Get the entity with given id.

Parameters

id – entity_id

Return type

Entity

get_root_entities(*, include_params=True, entity_type_names=None)

Get the root entities.

Parameters
  • include_params (bool) – True to include the parameters of the root entities.

  • entity_type_names (Optional[List[str]]) – Only filters the entities of the defined type(s) (default = None, returns all).

Return type

EntityList

get_entity_file(entity_id)

Get the file of the entity.

Parameters

entity_id (int) – id of the entity to get the file from.

Return type

File

Returns

File object (SourceType.URL)

Raises

ValueError – if file does not have a file associated with it.

get_current_user()
Return type

User