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.2.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.2.0
File Size Uploaded Provenance Actions
gemini_tender-0.2.0.tar.gz 7.3 kB Without provenance Details for gemini_tender-0.2.0.tar.gz

Built distribution (wheel)

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

Total release size: 15.5 kB

Release files / gemini_tender-0.2.0.tar.gz

Download URL gemini_tender-0.2.0.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
52f206332044bdff77c9ea509907f62c9523f7c715a3088ccfdd5a98c57d55f5
BLAKE2b-256 checksum
How to use checksums
0a1c4f59a5cdc8fefe215d53a16086d1bed76ddcf61dbaf201b8975e38f78c82
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.2.0-py3-none-any.whl

Download URL gemini_tender-0.2.0-py3-none-any.whl
Size 8.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3d3dcb0805abfdc52951b14f4360fb0e5dcf0c484a4704fdf62eb6db7e66287b
BLAKE2b-256 checksum
How to use checksums
713801429b2a7af87e63ffa0af5ecc370fec25d93da564341c6072efba9d3cc1
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.2.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