Skip to main content

Tender

A Gemini (the protocol) low-level client, implemented in Python.

Python versions Version License

PyPI - Documentation - Source code - Issue tracker - Changelog

Prerequisites

  • Python >= 3.14

Installation

Use your favorite Python package manager to install gemini-tender. Example using Pipenv:

pipenv install gemini-tender

Usage

Setting up the SSL context

The Gemini protocol requires usage of TLS >= 1.2. The first thing you thus have to do is to set up an SSL context.

A bare-minimum, Gemini-compliant context can be created and used right away:

import tender

context = tender.create_default_ssl_context()

This method creates a preconfigured ssl.SSLContext instance. However, this context will not - by default - validate any certificate and will accept any certificate.

Using a client certificate

Create a default SSL context, and set your certificates using Python's methods:

import tender

context = tender.create_default_ssl_context()
context.load_cert_chain('cert.pem', 'key.pem')

Note that you must of course use one context per identity.

Sending requests

As simple as (all examples assume you already have an asyncio context):

import tender

context = ...

try:
    response = await tender.request('gemini://geminiprotocol.net/', context)
except ValueError:
    # On invalid URL or malformed response
    ...
except OSError:
    # All other errors
    ...

A tender.Response instance will be returned.

Custom timeout

There's a 5-second timeout by default for the whole request process. You can change that with the third timeout argument:

import tender

context = ...

try:
    response = await tender.request('gemini://geminiprotocol.net/', context, timeout=10) # 10 seconds
except TimeoutError: # Note it's an OSError subclass
    # Timeout reached
    ...
except ValueError:
    # On invalid URL or malformed response
    ...
except OSError:
    # All other errors
    ...

Inspecting the response

Several attributes and methods in tender.Response are available:

  • is_failure() determines whether the status is a permanent or temporary failure
  • is_input(), is_success(), is_redirect(), is_tempfail(), is_permfail() and is_auth() determine the status group
  • status is the status as an integer
  • For input responses:
    • prompt is the prompt as a string
  • For success responses:
    • body is the raw response body as bytes
    • mime_type is a tender.MimeType instance (read below for more info)
    • gemtext may be a tender.Gemtext instance if the returned MIME type is text/gemini, or None instead. Read below for more info
  • For redirect responses:
    • uri is the redirect URI as a string
  • For temporary failure, permanent failure and auth responses:
    • error_msg is the error message as a string or None if there is none

Inspecting the response's MIME type

tender.MimeType is a named tuple, with the following attributes:

  • media_type - a string containing the actual MIME type (e.g. text/gemini)
  • parameters - a dictionary containing the associated parameters (e.g. {'charset': 'utf-8', 'lang': 'fr'})

Reading the parsed gemtext

tender.Gemtext exposes the following attributes:

  • lines - a list of parsed lines constituting the gemtext document. This list may contain instances of the following named tuples and associated attributes:
    • tender.Text (text - string)
    • tender.Link (url - string, label - string or None)
    • tender.Heading1 (text - string)
    • tender.Heading2 (text - string)
    • tender.Heading3 (text - string)
    • tender.ListItem (text - string)
    • tender.Quote (text - string)
    • tender.Preformatted (text - string, alt - string or None)
  • lang - a list of language codes, parsed from the response's MIME type, or None if there's none

Development

Getting source code and installing the package

Requires pip >= 25.1.

  1. Clone the repository
  2. From the package's root: pip install --editable . --group dev

Releasing the package

  1. __version__ in src/tender/__init__.py must be updated beforehand. It should adhere to Semantic Versioning
  2. Create an associated Git tag (must exactly match the aforementioned version)
  3. rm -rf dist/ && python -m build
  4. twine upload dist/*
  5. An associated GitHub release must be created following the Keep a Changelog format

Metadata

Release files for gemini-tender 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gemini-tender 0.1.0
File Size Uploaded Provenance Actions
gemini_tender-0.1.0.tar.gz 6.5 kB Without provenance Details for gemini_tender-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for gemini-tender 0.1.0
File Interpreter ABI Platform Actions
gemini_tender-0.1.0-py3-none-any.whl Python 3 none any Details for gemini_tender-0.1.0-py3-none-any.whl

Total release size: 13.8 kB

Release files / gemini_tender-0.1.0.tar.gz

Download URL gemini_tender-0.1.0.tar.gz
Size 6.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7e2a30565444b7c4fc3109cb696f203e11f8d54110bfa931c6e9fedf0ed26eab
BLAKE2b-256 checksum
How to use checksums
5c53007739910a447f30abd115e5337ee5be1b7eec274f1d7d1d64cfe6781aa3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Release files / gemini_tender-0.1.0-py3-none-any.whl

Download URL gemini_tender-0.1.0-py3-none-any.whl
Size 7.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
811abfb38bc36ef5b9afbba354d078062a549463e75b2facd26e42d2cc2c2b53
BLAKE2b-256 checksum
How to use checksums
c1361e4b8358f7a121b77a0f6aebd9f43d1ee73a5133648e15d2572c6a324edb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.5

Security for gemini-tender 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page