Skip to main content

A toolkit for implementing tRPC servers in python

Project description

trpc-core

Toolkit for implementing tRPC servers in python

trpc-core is currently in prototype stage. You are welcome to play with the code or drop feedback in issues, just don't expect anything usable or functional yet.

Example tRPC API with Flask:

import trpc
from flask import Flask, jsonify, request


class Router(trpc.Router):
    @trpc.query(name="helloWorld")
    def hello_world(context) -> str:
        return "Hello world"

    @trpc.mutation(name="sum")
    def sum(context, *, a: int, b: int) -> int:
        return a + b


server = trpc.Server(Router)


app = Flask(__name__)


@app.route("/trpc/<path:path>", methods=["GET"])
def trpc_query(path):
    result = server.query(path)
    return jsonify(result)


@app.route("/trpc/<path:path>", methods=["POST"])
def trpc_mutation(path):
    result = server.mutation(path)
    return jsonify(result)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trpc_core-0.1.0.tar.gz (3.9 kB view details)

Uploaded Source

Built Distribution

trpc_core-0.1.0-py2.py3-none-any.whl (6.4 kB view details)

Uploaded Python 2 Python 3

File details

Details for the file trpc_core-0.1.0.tar.gz.

File metadata

  • Download URL: trpc_core-0.1.0.tar.gz
  • Upload date:
  • Size: 3.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for trpc_core-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a76828a6dfe1dca26ca65594fa1e642278353c4c853d87659b2f4797af70b52c
MD5 9db7e4fad8ee49e3c8a9044c935fe8eb
BLAKE2b-256 37bdb2bb55cbaec88630e15e8c717efbba311ab94896d6f1cc4682b18bf2e76a

See more details on using hashes here.

File details

Details for the file trpc_core-0.1.0-py2.py3-none-any.whl.

File metadata

  • Download URL: trpc_core-0.1.0-py2.py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.1

File hashes

Hashes for trpc_core-0.1.0-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 93ba9b5fd1b123e3771973f7b7e3e1c9e38a26d13ed3737b6d24ac8450775025
MD5 e21fd8c70c20e0aafb4593b7e610ebfc
BLAKE2b-256 160f1f560df428061cd8f1cfa7c0b385e2c56d3562b6e15f35ef33702575371b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page