Skip to main content

Documents and files

MethodDescription
list_documentsList documents.
iter_documentsIterate over documents.
get_documentGet a document by SID.
create_document_from_markdownCreate a document from markdown text or a UTF-8 markdown file.
list_raw_filesList raw files.
iter_raw_filesIterate over raw files.
get_raw_fileGet a raw file by SID.
upload_imageUpload an image for use in Jinko documents.
list_referencesList references.
iter_referencesIterate over references.
get_referenceGet a reference by SID.
create_reference_from_pdfCreate a reference from a PDF file.
create_reference_from_doiCreate a reference from a DOI and fetch its bibliography metadata.
create_extractCreate an extract from a reference.

list_documents​

list_documents(
*,
name: str | None = None,
folder: Folder | str | None = None,
limit: int | None = None,
deleted: bool = False,
after: str | None = None
) -> Page["Document"]

List documents.

Parameters:

NameTypeDescriptionDefault
namestr | NoneOptional name filter.None
folderFolder | str | NoneOptional folder filter.None
limitint | NoneMaximum number of results to return.None
deletedboolWhether to include deleted documents.False
afterstr | NonePagination cursor.None

Returns:

  • Page['Document']: A page of Document objects.

iter_documents​

iter_documents(
*,
name: str | None = None,
folder: Folder | str | None = None,
deleted: bool = False
) -> Iterator["Document"]

Iterate over documents.

Parameters:

NameTypeDescriptionDefault
namestr | NoneOptional name filter.None
folderFolder | str | NoneOptional folder filter.None
deletedboolWhether to include deleted documents.False

Yields:

get_document​

get_document(
sid: str, *, revision: int | None = None, allow_deleted: bool = False
) -> Document

Get a document by SID.

Parameters:

NameTypeDescriptionDefault
sidstrThe SID of the document.
revisionint | NoneOptional revision number.None
allow_deletedboolWhether to allow retrieving deleted documents.False

Returns:

create_document_from_markdown​

create_document_from_markdown(
*,
markdown_content: str | bytes | None = None,
markdown_file_path: str | Path | None = None,
name: str | None = None,
folder: Folder | str | None = None,
description: str | None = None,
version: str | dict | None = None
) -> Document

Create a document from markdown text or a UTF-8 markdown file.

The document body accepts standard Markdown and extends it with Jinko- specific URL handling. Common Markdown features such as headings, lists, emphasis, tables, code blocks, links, and images are supported.

In addition, Jinko URLs can be used directly in the markdown:

  • A project item's .url on its own line can render as a rich Jinko embed.
  • An uploaded image's .url can be used directly or as a normal Markdown image target.
  • External HTTPS URLs keep normal Markdown link or image behavior.

Exactly one of markdown_content or markdown_file_path must be provided.

The supplied markdown becomes the full initial body of the new document.

Examples:

Create a document that references a model, an uploaded image, and an external URL:

model = client.create_empty_model("PK starter model")
image = client.upload_image(image_file_path="assets/overview.png")
document = client.create_document_from_markdown(
markdown_content=f"""# Study Overview

This document uses standard Markdown plus Jinko URLs.

Embedded model:

{model.url}

Embedded image:

![Workflow diagram]({image.url})

Links: [Model card]({model.url}) and
[Company site](https://www.novainsilico.ai/jinko).
""",
name="Study Overview",
)

Create a document from a markdown file:

document = client.create_document_from_markdown(
markdown_file_path="docs/study-overview.md",
name="Study Overview",
)

list_raw_files​

list_raw_files(
*,
name: str | None = None,
folder: Folder | str | None = None,
limit: int | None = None,
deleted: bool = False,
after: str | None = None
) -> Page["RawFile"]

List raw files.

Parameters:

NameTypeDescriptionDefault
namestr | NoneOptional name filter.None
folderFolder | str | NoneOptional folder filter.None
limitint | NoneMaximum number of results to return.None
deletedboolWhether to include deleted raw files.False
afterstr | NonePagination cursor.None

Returns:

  • Page['RawFile']: A page of RawFile objects.

iter_raw_files​

iter_raw_files(
*,
name: str | None = None,
folder: Folder | str | None = None,
deleted: bool = False
) -> Iterator["RawFile"]

Iterate over raw files.

Parameters:

NameTypeDescriptionDefault
namestr | NoneOptional name filter.None
folderFolder | str | NoneOptional folder filter.None
deletedboolWhether to include deleted raw files.False

Yields:

get_raw_file​

get_raw_file(
sid: str, *, revision: int | None = None, allow_deleted: bool = False
) -> RawFile

Get a raw file by SID.

Parameters:

NameTypeDescriptionDefault
sidstrThe SID of the raw file.
revisionint | NoneOptional revision number.None
allow_deletedboolWhether to allow retrieving deleted raw files.False

Returns:

upload_image​

upload_image(
*,
image_content: bytes | None = None,
image_file_path: str | Path | None = None
) -> File

Upload an image for use in Jinko documents.

This uploads to the document image route and returns a File whose .url can be inserted into document markdown. Uploaded images can be used in a Document Project Item, including as a standalone URL or in a normal Markdown image such as ![Alt text](...). This works in documents created with create_document_from_markdown() or updated with Document.update_markdown().

Exactly one of image_content or image_file_path must be provided.

Examples:

Upload an image from disk and use it in markdown:

image = client.upload_image(image_file_path="assets/overview.png")
document = client.create_document_from_markdown(
markdown_content=f"{image.url}\n\n![Overview]({image.url})",
name="Overview",
)

Upload image bytes and mix the image with project item and external URLs:

image = client.upload_image(image_content=image_bytes)
model = client.create_empty_model("PK starter model")
document = client.create_document_from_markdown(
markdown_content=f"""# Report

{model.url}

![Rendered plot]({image.url})

More context: https://docs.jinko.ai/
""",
name="Report",
)

Parameters:

NameTypeDescriptionDefault
image_contentbytes | NoneThe image data as bytes.None
image_file_pathstr | Path | NonePath to an image file.None

Returns:

  • File: The uploaded File.

list_references​

list_references(
*,
name: str | None = None,
folder: Folder | str | None = None,
limit: int | None = None,
deleted: bool = False,
after: str | None = None
) -> Page["Reference"]

List references.

Parameters:

NameTypeDescriptionDefault
namestr | NoneOptional name filter.None
folderFolder | str | NoneOptional folder filter.None
limitint | NoneMaximum number of results to return.None
deletedboolWhether to include deleted references.False
afterstr | NonePagination cursor.None

Returns:

  • Page['Reference']: A page of Reference objects.

iter_references​

iter_references(
*,
name: str | None = None,
folder: Folder | str | None = None,
deleted: bool = False
) -> Iterator["Reference"]

Iterate over references.

Parameters:

NameTypeDescriptionDefault
namestr | NoneOptional name filter.None
folderFolder | str | NoneOptional folder filter.None
deletedboolWhether to include deleted references.False

Yields:

get_reference​

get_reference(
sid: str, *, revision: int | None = None, allow_deleted: bool = False
) -> Reference

Get a reference by SID.

Parameters:

NameTypeDescriptionDefault
sidstrThe SID of the reference.
revisionint | NoneOptional revision number.None
allow_deletedboolWhether to allow retrieving deleted references.False

Returns:

create_reference_from_pdf​

create_reference_from_pdf(
*,
pdf_content: bytes | None = None,
pdf_file_path: str | Path | None = None,
name: str | None = None,
folder: Folder | str | None = None,
description: str | None = None,
version: str | dict | None = None,
auto_extract_from_ocr: bool | None = None
) -> Reference

Create a reference from a PDF file.

Exactly one of pdf_content or pdf_file_path must be provided.

Parameters:

NameTypeDescriptionDefault
pdf_contentbytes | NoneThe PDF data as bytes.None
pdf_file_pathstr | Path | NonePath to a PDF file.None
namestr | NoneOptional name for the new project item.None
folderFolder | str | NoneOptional destination folder.None
descriptionstr | NoneOptional description for the new project item.None
versionstr | dict | NoneOptional version name str. Can also be a dict with the keys name and description to set a version description.None
auto_extract_from_ocrbool | NoneWhether to automatically extract figures and tables using OCR. The extracts are then available through Reference.list_extracts() on the returned object. Defaults to no extraction when omitted.None

Returns:

create_reference_from_doi​

create_reference_from_doi(
doi: str,
*,
name: str | None = None,
folder: Folder | str | None = None,
description: str | None = None,
auto_extract_from_ocr: bool | None = None
) -> Reference

Create a reference from a DOI and fetch its bibliography metadata.

Parameters:

NameTypeDescriptionDefault
doistrDOI of the reference.
namestr | NoneOptional name; defaults to the bibliography title.None
folderFolder | str | NoneOptional destination folder.None
descriptionstr | NoneOptional description for the new project item.None
auto_extract_from_ocrbool | NoneWhether to automatically extract figures and tables using OCR if a PDF is attached later. The extracts are then available through Reference.list_extracts() on the returned object. Defaults to no extraction when omitted.None

Returns:

create_extract​

create_extract(
reference: Reference,
*,
anchors: Sequence[Mapping[str, Any]],
text: str | None = None,
latex: str | None = None,
mathjs: str | None = None,
data_table: DataTable | str | None = None,
color: (
Literal["Cyan", "Green", "Grey", "Orange", "Pink", "Purple", "Red"]
| None
) = None,
classification_type: (
Literal["Statement", "Hypothesis", "Data"] | None
) = None,
classification_level: (
Literal["Weak", "Medium", "Strong", "Excellent"] | None
) = None,
name: str | None = None,
folder: Folder | str | None = None,
description: str | None = None,
version: str | dict[str, str] | None = None
) -> Extract

Create an extract from a reference.

reference must be a Reference object.

anchors must be a non-empty sequence of mappings. Each anchor must provide page, x, y, width, and height.

x and y start from the top-left corner of the page. width and height extend rightward and downward from that point.

Multiple anchors are typically used for multi-line text selections. For non-text rectangular extracts, only the first anchor is meaningful.

Provide at most one of text, latex, and data_table. Text creates a textual extract; latex creates a formula extract, with an optional MathJS expression; and data_table creates an extract linked to that data table. When all three are omitted, a rectangular extract is created.

When color is None, the extract color defaults to Green.

When classification_type is provided without a level, the extract is created as unevaluated. Hypothesis classifications do not support the Excellent level.