Python API

Quick Start

from plaid_client import PlaidClient

client = PlaidClient.login("http://localhost:8085", "user@example.com", "password")

# Create a project
project = client.projects.create("My Project")

# Create a document
doc = client.documents.create(project["id"], "Document 1")

# List a project's documents
docs = client.projects.list_documents(project["id"])

# Batch multiple operations atomically
client.begin_batch()
client.tokens.create(token_layer_id, text_id, 0, 5)
client.tokens.create(token_layer_id, text_id, 6, 11)
results = client.submit_batch()

Client

__init__(base_url, token, timeout)

Create a new PlaidClient instance.

ParameterTypeDescription
base_url Any The base URL for the API
token Any The authentication token
timeout Any Per-request timeout in seconds (default 30; ``None`` disables
query(body)

Run a query over every project you can read.

ParameterTypeDescription
body Any The query AST ({find, where, scope?, limit?, order_by?,
enter_strict_mode(document_id)

Enter strict mode for a specific document.

ParameterTypeDescription
document_id Any The ID of the document to track versions for
exit_strict_mode()

Exit strict mode and stop tracking document versions for writes.

set_audit_message()

Set a custom audit-log message applied to every subsequent write,

clear_audit_message()

Clear the ambient custom audit-log message (revert to auto-generated).

audit_message() @contextmanager

Run the block with a custom audit-log message in effect, restoring

begin_batch()

Begin a batch of operations. Subsequent API calls will be queued.

submit_batch()

Submit all queued batch operations as a single batch request.

abort_batch()

Abort the current batch without executing any operations.

is_batch_mode()

Check if currently in batch mode.

batched() @contextmanager

Collect the calls in this block into ONE atomic batch request.

close()

Close the underlying HTTP session.

Api Tokens

api_tokens.list(user_id)

List a user's named API tokens.

ParameterTypeDescription
user_id Any The user ID who owns the tokens
api_tokens.iter_pages(user_id, page_size)

Iterate over pages of a user's API tokens, yielding each page's entries.

ParameterTypeDescription
user_id Any The user ID who owns the tokens
page_size Any Page size (1..1000)
api_tokens.create(user_id, name)

Mint a named API token for a user.

ParameterTypeDescription
user_id Any The user ID who will own the token
name Any A human label, e.g. "Stanza Parser"
api_tokens.revoke(user_id, token_id)

Revoke a named API token (soft-revoke; idempotent).

ParameterTypeDescription
user_id Any The user ID who owns the token
token_id Any The token ID to revoke

Batch

batch.submit(body)

Execute multiple API operations atomically.

ParameterTypeDescription
body Any The request body

Documents

documents.check_lock(document_id, as_of)

Get information about a document lock.

ParameterTypeDescription
document_id Any The document ID
as_of Any Temporal query timestamp
documents.acquire_lock(document_id)

Acquire or refresh a document lock.

ParameterTypeDescription
document_id Any The document ID
documents.release_lock(document_id)

Release a document lock.

ParameterTypeDescription
document_id Any The document ID
documents.locked() @contextmanager

Hold this document's server-enforced lock for a ``with`` block,

documents.get_media(document_id, as_of)

Get media file for a document.

ParameterTypeDescription
document_id Any The document ID
as_of Any Temporal query timestamp
documents.upload_media(document_id, file)

Upload a media file for a document. Uses Apache Tika for content validation.

ParameterTypeDescription
document_id Any The document ID
file Any The file to upload
documents.delete_media(document_id)

Delete media file for a document.

ParameterTypeDescription
document_id Any The document ID
documents.delete(document_id)

Delete a document and all data contained.

ParameterTypeDescription
document_id Any The document ID
documents.update(document_id, name)

Update a document's name.

ParameterTypeDescription
document_id Any The document ID
name Any The name
documents.create(project_id, name, metadata)

Create a new document in a project.

ParameterTypeDescription
project_id Any The project ID
name Any The name
metadata Any Metadata map. Omit to leave unset; pass ``None`` to send
documents.set_metadata(document_id, body)

Replace all metadata for a document.

ParameterTypeDescription
document_id Any The document ID
body Any The request body
documents.delete_metadata(document_id)

Remove all metadata from a document.

ParameterTypeDescription
document_id Any The document ID
documents.patch_metadata(document_id, body)

Patch (shallow-merge) metadata for a document.

ParameterTypeDescription
document_id Any The document ID
body Any The metadata patch

Messages

messages.listen(project_id, on_event, path)

Open a Server-Sent Events stream for a project.

ParameterTypeDescription
project_id Any The UUID of the project to listen to
on_event Any Callback function that receives (event_type, data). If it
path Any Stream path under the base URL. Defaults to the project
messages.send_message(project_id, data)

Send a message to project listeners.

ParameterTypeDescription
project_id Any The UUID of the project to send to
data Any The message data to send
messages.discover_services(project_id)

Discover the services seen on a project.

ParameterTypeDescription
project_id Any The UUID of the project to query
messages.discard_service(project_id, service_id)

Forget a previously-seen (offline) service.

ParameterTypeDescription
project_id Any The UUID of the project
service_id Any The ID of the service to forget

Projects

projects.create(name)

Create a new project.

ParameterTypeDescription
name Any The name
projects.list(as_of)

List all projects accessible to the current user.

ParameterTypeDescription
as_of Any Temporal query timestamp
projects.iter_pages(page_size, as_of)

Iterate over pages of projects, yielding each page's entries list.

ParameterTypeDescription
page_size Any Page size (1..1000)
as_of Any Temporal query timestamp
projects.list_documents(id)

List all documents (IDs and names) in a project.

ParameterTypeDescription
id Any The project ID
projects.iter_documents(id, page_size)

Iterate over pages of a project's documents, yielding each page's entries.

ParameterTypeDescription
id Any The project ID
page_size Any Page size (1..1000)
projects.get(id, as_of)

Get a project by ID.

ParameterTypeDescription
id Any The resource ID
as_of Any Temporal query timestamp
projects.delete(id, audit_message, timeout)

Delete a project and everything in it. This is irrecoverable.

ParameterTypeDescription
id Any The resource ID
audit_message Any Custom audit-log message.
timeout Any Per-request timeout in seconds; ``None`` (default) disables it.
projects.update(id, name)

Update a project's name.

ParameterTypeDescription
id Any The resource ID
name Any The name
projects.add_writer(id, user_id)

Set a user's access level to read and write for this project.

ParameterTypeDescription
id Any The resource ID
user_id Any The user ID
projects.remove_writer(id, user_id)

Remove a user's writer privileges for this project.

ParameterTypeDescription
id Any The resource ID
user_id Any The user ID
projects.add_reader(id, user_id)

Set a user's access level to read-only for this project.

ParameterTypeDescription
id Any The resource ID
user_id Any The user ID
projects.remove_reader(id, user_id)

Remove a user's reader privileges for this project.

ParameterTypeDescription
id Any The resource ID
user_id Any The user ID
projects.add_maintainer(id, user_id)

Assign a user as a maintainer for this project.

ParameterTypeDescription
id Any The resource ID
user_id Any The user ID
projects.remove_maintainer(id, user_id)

Remove a user's maintainer privileges for this project.

ParameterTypeDescription
id Any The resource ID
user_id Any The user ID
projects.set_config(id, namespace, config_key, config_value)

Set a configuration value for a project in an editor namespace.

ParameterTypeDescription
id Any The resource ID
namespace Any The config namespace
config_key Any The config key
config_value Any Configuration value to set
projects.delete_config(id, namespace, config_key)

Remove a configuration value for a project.

ParameterTypeDescription
id Any The resource ID
namespace Any The config namespace
config_key Any The config key

Relation Layers

relation_layers.get(relation_layer_id, as_of)

Get a relation layer by ID.

ParameterTypeDescription
relation_layer_id Any The relation layer ID
as_of Any Temporal query timestamp
relation_layers.delete(relation_layer_id)

Delete a relation layer.

ParameterTypeDescription
relation_layer_id Any The relation layer ID
relation_layers.update(relation_layer_id, name)

Update a relation layer's name.

ParameterTypeDescription
relation_layer_id Any The relation layer ID
name Any The name
relation_layers.set_config(relation_layer_id, namespace, config_key, config_value)

Set a configuration value for a relation layer in an editor namespace.

ParameterTypeDescription
relation_layer_id Any The relation layer ID
namespace Any The config namespace
config_key Any The config key
config_value Any Configuration value to set
relation_layers.delete_config(relation_layer_id, namespace, config_key)

Remove a configuration value for a relation layer.

ParameterTypeDescription
relation_layer_id Any The relation layer ID
namespace Any The config namespace
config_key Any The config key
relation_layers.shift(relation_layer_id, direction)

Shift a relation layer's display order.

ParameterTypeDescription
relation_layer_id Any The relation layer ID
direction Any The direction ("up" or "down")
relation_layers.create(span_layer_id, name)

Create a new relation layer.

ParameterTypeDescription
span_layer_id Any The span layer ID
name Any The name

Relations

relations.set_metadata(relation_id, body)

Replace all metadata for a relation.

ParameterTypeDescription
relation_id Any The relation ID
body Any The request body
relations.delete_metadata(relation_id)

Remove all metadata from a relation.

ParameterTypeDescription
relation_id Any The relation ID
relations.patch_metadata(relation_id, body)

Patch (shallow-merge) metadata for a relation.

ParameterTypeDescription
relation_id Any The relation ID
body Any The metadata patch
relations.set_target(relation_id, span_id)

Update the target span of a relation.

ParameterTypeDescription
relation_id Any The relation ID
span_id Any The span ID
relations.set_source(relation_id, span_id)

Update the source span of a relation.

ParameterTypeDescription
relation_id Any The relation ID
span_id Any The span ID
relations.get(relation_id, as_of)

Get a relation by ID.

ParameterTypeDescription
relation_id Any The relation ID
as_of Any Temporal query timestamp
relations.delete(relation_id)

Delete a relation.

ParameterTypeDescription
relation_id Any The relation ID
relations.update(relation_id, value)

Update a relation's value.

ParameterTypeDescription
relation_id Any The relation ID
value Any The value
relations.bulk_create(body)

Create multiple relations in a single operation.

ParameterTypeDescription
body Any The request body
relations.bulk_delete(body)

Delete multiple relations in a single operation. Provide a list of IDs.

ParameterTypeDescription
body Any The request body

Span Layers

span_layers.get(span_layer_id, as_of)

Get a span layer by ID.

ParameterTypeDescription
span_layer_id Any The span layer ID
as_of Any Temporal query timestamp
span_layers.delete(span_layer_id)

Delete a span layer.

ParameterTypeDescription
span_layer_id Any The span layer ID
span_layers.update(span_layer_id, name)

Update a span layer's name.

ParameterTypeDescription
span_layer_id Any The span layer ID
name Any The name
span_layers.set_config(span_layer_id, namespace, config_key, config_value)

Set a configuration value for a span layer in an editor namespace.

ParameterTypeDescription
span_layer_id Any The span layer ID
namespace Any The config namespace
config_key Any The config key
config_value Any Configuration value to set
span_layers.delete_config(span_layer_id, namespace, config_key)

Remove a configuration value for a span layer.

ParameterTypeDescription
span_layer_id Any The span layer ID
namespace Any The config namespace
config_key Any The config key
span_layers.shift(span_layer_id, direction)

Shift a span layer's display order.

ParameterTypeDescription
span_layer_id Any The span layer ID
direction Any The direction ("up" or "down")
span_layers.create(token_layer_id, name)

Create a new span layer.

ParameterTypeDescription
token_layer_id Any The token layer ID
name Any The name

Spans

spans.set_metadata(span_id, body)

Replace all metadata for a span.

ParameterTypeDescription
span_id Any The span ID
body Any The request body
spans.delete_metadata(span_id)

Remove all metadata from a span.

ParameterTypeDescription
span_id Any The span ID
spans.patch_metadata(span_id, body)

Patch (shallow-merge) metadata for a span.

ParameterTypeDescription
span_id Any The span ID
body Any The metadata patch
spans.set_tokens(span_id, tokens)

Replace the tokens associated with a span.

ParameterTypeDescription
span_id Any The span ID
tokens Any The tokens
spans.get(span_id, as_of)

Get a span by ID.

ParameterTypeDescription
span_id Any The span ID
as_of Any Temporal query timestamp
spans.delete(span_id)

Delete a span.

ParameterTypeDescription
span_id Any The span ID
spans.update(span_id, value)

Update a span's value.

ParameterTypeDescription
span_id Any The span ID
value Any The value
spans.create(span_layer_id, tokens, value, metadata)

Create a new span.

ParameterTypeDescription
span_layer_id Any The span layer ID
tokens Any The tokens
value Any The value
metadata Any Metadata map. Omit to leave unset; pass ``None`` to send
spans.bulk_create(body)

Create multiple spans in a single operation.

ParameterTypeDescription
body Any The request body
spans.bulk_delete(body)

Delete multiple spans in a single operation. Provide a list of IDs.

ParameterTypeDescription
body Any The request body

Text Layers

text_layers.get(text_layer_id, as_of)

Get a text layer by ID.

ParameterTypeDescription
text_layer_id Any The text layer ID
as_of Any Temporal query timestamp
text_layers.delete(text_layer_id)

Delete a text layer.

ParameterTypeDescription
text_layer_id Any The text layer ID
text_layers.update(text_layer_id, name)

Update a text layer's name.

ParameterTypeDescription
text_layer_id Any The text layer ID
name Any The name
text_layers.set_config(text_layer_id, namespace, config_key, config_value)

Set a configuration value for a text layer in an editor namespace.

ParameterTypeDescription
text_layer_id Any The text layer ID
namespace Any The config namespace
config_key Any The config key
config_value Any Configuration value to set
text_layers.delete_config(text_layer_id, namespace, config_key)

Remove a configuration value for a text layer.

ParameterTypeDescription
text_layer_id Any The text layer ID
namespace Any The config namespace
config_key Any The config key
text_layers.shift(text_layer_id, direction)

Shift a text layer's order within the project.

ParameterTypeDescription
text_layer_id Any The text layer ID
direction Any The direction ("up" or "down")
text_layers.create(project_id, name)

Create a new text layer for a project.

ParameterTypeDescription
project_id Any The project ID
name Any The name

Texts

texts.get(text_id, as_of)

Get a text.

ParameterTypeDescription
text_id Any The text ID
as_of Any Temporal query timestamp
texts.delete(text_id)

Delete a text and all dependent data.

ParameterTypeDescription
text_id Any The text ID
texts.update(text_id, body)

Update a text's ``body``.

ParameterTypeDescription
text_id Any The text ID
body Any The request body
texts.set_metadata(text_id, body)

Replace all metadata for a text.

ParameterTypeDescription
text_id Any The text ID
body Any The request body
texts.delete_metadata(text_id)

Remove all metadata from a text.

ParameterTypeDescription
text_id Any The text ID
texts.patch_metadata(text_id, body)

Patch (shallow-merge) metadata for a text.

ParameterTypeDescription
text_id Any The text ID
body Any The metadata patch

Token Layers

token_layers.get(token_layer_id, as_of)

Get a token layer by ID.

ParameterTypeDescription
token_layer_id Any The token layer ID
as_of Any Temporal query timestamp
token_layers.delete(token_layer_id)

Delete a token layer.

ParameterTypeDescription
token_layer_id Any The token layer ID
token_layers.update(token_layer_id, name)

Update a token layer's name.

ParameterTypeDescription
token_layer_id Any The token layer ID
name Any The name
token_layers.set_config(token_layer_id, namespace, config_key, config_value)

Set a configuration value for a token layer in an editor namespace.

ParameterTypeDescription
token_layer_id Any The token layer ID
namespace Any The config namespace
config_key Any The config key
config_value Any Configuration value to set
token_layers.delete_config(token_layer_id, namespace, config_key)

Remove a configuration value for a token layer.

ParameterTypeDescription
token_layer_id Any The token layer ID
namespace Any The config namespace
config_key Any The config key
token_layers.shift(token_layer_id, direction)

Shift a token layer's display order.

ParameterTypeDescription
token_layer_id Any The token layer ID
direction Any The direction ("up" or "down")

Tokens

tokens.set_metadata(token_id, body)

Replace all metadata for a token.

ParameterTypeDescription
token_id Any The token ID
body Any The request body
tokens.delete_metadata(token_id)

Remove all metadata from a token.

ParameterTypeDescription
token_id Any The token ID
tokens.patch_metadata(token_id, body)

Patch (shallow-merge) metadata for a token.

ParameterTypeDescription
token_id Any The token ID
body Any The metadata patch
tokens.get(token_id, as_of)

Get a token.

ParameterTypeDescription
token_id Any The token ID
as_of Any Temporal query timestamp
tokens.delete(token_id)

Delete a token and remove it from any spans.

ParameterTypeDescription
token_id Any The token ID
tokens.bulk_create(body)

Create multiple tokens in a single operation.

ParameterTypeDescription
body Any The request body
tokens.bulk_delete(body)

Delete multiple tokens in a single operation. Provide a list of IDs.

ParameterTypeDescription
body Any The request body
tokens.split(token_id, position)

Split a token at a Unicode code-point offset.

ParameterTypeDescription
token_id Any The token ID
position Any Code-point offset to split at (strictly between begin and end)
tokens.merge(token_id, other_token_id)

Merge two tokens.

ParameterTypeDescription
token_id Any The anchor token ID
other_token_id Any The other token to merge in
tokens.shift(token_id, begin, end)

Shift a token's boundary.

ParameterTypeDescription
token_id Any The token ID
begin Any New start offset, inclusive (Unicode code points). Omit to leave unchanged.
end Any New end offset, exclusive (Unicode code points). Omit to leave unchanged.

Users

users.list(q, as_of)

List (or search) users. Admin-or-maintainer only.

ParameterTypeDescription
q Any Filter to usernames containing this text (case-insensitive)
as_of Any Temporal query timestamp
users.create(username, password, is_admin)

Create a new user.

ParameterTypeDescription
username Any The username
password Any The password
is_admin Any Whether the user is an admin
users.get(id, as_of)

Get a user by ID.

ParameterTypeDescription
id Any The resource ID
as_of Any Temporal query timestamp
users.delete(id)

Deactivate a user.

ParameterTypeDescription
id Any The resource ID
users.activate(id)

Reactivate a deactivated user, restoring their ability to log in.

ParameterTypeDescription
id Any The resource ID

Vocab Items

vocab_items.create(vocab_layer_id, form, metadata)

Create a new vocab item.

ParameterTypeDescription
vocab_layer_id Any The vocab layer ID
form Any The vocab item form
metadata Any Metadata map. Omit to leave unset; pass ``None`` to send
vocab_items.bulk_create(body)

Create multiple vocab items in a single operation.

ParameterTypeDescription
body Any The vocab items to create
vocab_items.bulk_delete(body)

Delete multiple vocab items in a single operation. Provide a list of IDs.

ParameterTypeDescription
body Any The vocab item IDs to delete
vocab_items.get(id, as_of)

Get a vocab item by ID.

ParameterTypeDescription
id Any The resource ID
as_of Any Temporal query timestamp
vocab_items.delete(id)

Delete a vocab item.

ParameterTypeDescription
id Any The resource ID
vocab_items.update(id, form)

Update a vocab item's form.

ParameterTypeDescription
id Any The resource ID
form Any The vocab item form
vocab_items.set_metadata(id, body)

Replace all metadata for a vocab item.

ParameterTypeDescription
id Any The resource ID
body Any The request body
vocab_items.delete_metadata(id)

Remove all metadata from a vocab item.

ParameterTypeDescription
id Any The resource ID
vocab_items.patch_metadata(id, body)

Patch (shallow-merge) metadata for a vocab item.

ParameterTypeDescription
id Any The resource ID
body Any The metadata patch

Vocab Layers

vocab_layers.get(id, include_items, as_of)

Get a vocab layer by ID.

ParameterTypeDescription
id Any The resource ID
include_items Any Include vocab items
as_of Any Temporal query timestamp
vocab_layers.delete(id)

Delete a vocab layer.

ParameterTypeDescription
id Any The resource ID
vocab_layers.update(id, name)

Update a vocab layer's name.

ParameterTypeDescription
id Any The resource ID
name Any The name
vocab_layers.set_config(id, namespace, config_key, config_value)

Set a configuration value for a vocab layer in an editor namespace.

ParameterTypeDescription
id Any The resource ID
namespace Any The config namespace
config_key Any The config key
config_value Any Configuration value to set
vocab_layers.delete_config(id, namespace, config_key)

Remove a configuration value for a vocab layer.

ParameterTypeDescription
id Any The resource ID
namespace Any The config namespace
config_key Any The config key
vocab_layers.list(as_of)

List all vocab layers accessible to the current user.

ParameterTypeDescription
as_of Any Temporal query timestamp
vocab_layers.iter_pages(page_size, as_of)

Iterate over pages of vocab layers, yielding each page's entries list.

ParameterTypeDescription
page_size Any Page size (1..1000)
as_of Any Temporal query timestamp
vocab_layers.create(name)

Create a new vocab layer.

ParameterTypeDescription
name Any The name
vocab_layers.add_maintainer(id, user_id)

Assign a user as a maintainer for this vocab layer.

ParameterTypeDescription
id Any The resource ID
user_id Any The user ID
vocab_layers.remove_maintainer(id, user_id)

Remove a user's maintainer privileges for this vocab layer.

ParameterTypeDescription
id Any The resource ID
user_id Any The user ID