Skip to main content

Async Python Client to The RTEX API Server

Installation

pip install rtex

Usage

The API surface of Rtex is spartan so this is basically the whole thing.

import asyncio

from rtex.client import AsyncRtexClient

async def amain():
  async with AsyncRtexClient() as rtex:
    res = rtex.create_render("\(x^2 + x - 1\)")

    if res.status == "success":
      with open("equation.png") as output_fd:
        await res.save_render(
          res.filename,
          output_fd
        )

def main():
  asyncio.run(amain())

if __name__ == "__main__":
  main()

No Thoughts, Just Render

async def amain():
  async with AsyncRtexClient() as rtex:
    buf = await rtex.render_math("e^x + 1")

    # `buf` now contains the bytes of the PNG

Do I look like I know what a Jay-Peg is?

async def amain():
  async with AsyncRtexClient() as rtex:
    # The render methods accept a format parameter.
    # Supported values are "png", "jpg" and "pdf"
    buf = await rtex.render_math("e^x + 1", format="jpg")

Self-Hoster

Set the environment variable RTEX_API_HOST or do the following.

async def amain():
  async with AsyncRtexClient(api_host="https://myserver.ru") as rtex:
    buf = await rtex.render_math("e^x + 1")

I Can Tell By The Pixels

quality in Rtex speak is an abstract notion of compression for the given format where 100 is the least compressed and 0 is the most. At the time of writing the default is 85.

density in Rtex speak is how much to sample the rendered PDF when generating an image. This has no effect on the "pdf" format. At the time of writing the default is 200.

async def amain():
  async with AsyncRtexClient(api_host="https://myserver.ru") as rtex:
    needs_more_jpeg = await rtex.render_math(
      "e^x + 1",
      density=50,
      quality=1
    )

Release files for rtex 0.0.7

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

Source distribution (sdist)

Source distribution for rtex 0.0.7
File Size Uploaded
rtex-0.0.7.tar.gz 7.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for rtex 0.0.7
File Interpreter ABI Platform
rtex-0.0.7-py3-none-any.whl Python 3 none any Details

Total release size: 12.8 kB

Release files / rtex-0.0.7.tar.gz

Download URL rtex-0.0.7.tar.gz
Size 7.3 kB
Tags Source
SHA-256 checksum
How to use checksums
41a7aa1185419d188b0c935bfc09b05e82aab32ffff8e1312333d1969a456424
BLAKE2b-256 checksum
How to use checksums
1c4fc86fdcabcec74b11c57e85abe4db026cea5b64c24dc842c444888222bb99
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release files / rtex-0.0.7-py3-none-any.whl

Download URL rtex-0.0.7-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d64137eff4475e400fd6e66f8c31cdde6826ecbc1ce2a1795bddefac450be1ba
BLAKE2b-256 checksum
How to use checksums
df63718c263623e9c59258a32c8ec7173e4b351ea45964759f90b000a6c7283a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.9

Release history Release notifications | RSS feed

This release

0.0.7 This release

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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