QuickstartΒΆ

Snip is distributed on PyPI. To use the package:

  1. Install the package using pip:

pip install snip-python
  1. Use the snip command line interface (CLI) to interact with your lab books. For example, you can use the snip token command to store and retrieve your API tokens.

snip token --help
  1. Create and upload snippets to your lab books programmatically using the Python API.

from snip.snippets import ImageSnip

snip = ImageSnip.from_path("path/to/image.png", book_id="[YOUR_BOOK_ID]")

# show a preview of the snippet
snip.preview()

If you need help figuring out where to find the book id, please have a look here.

# upload the snippet
snip.upload()

The upload will automatically search your tokens in the keyring or in the configuration file and use the correct token to upload the snippet.