A Python remote procedure call framework that uses JSON RPC v2.0

Install using pip:

pip install python-jrpc

Socket Based Usage

Python-JRPC allows programmers to create powerful client/server programs with very little code. Here's an example of a server and client:


import jrpc

class SimpleService(jrpc.service.SocketObject):
    def echo(self, msg):
        return msg

server = SimpleService(50001) #Include the listening port


import jrpc

server = None
server = jrpc.service.SocketProxy(50001) #The server's listening port
print server.echo("Hello World!")

Web Based (Flask) Usage

A recent addition to Python JRPC offers Flask integration. Using this feature, client side Javascript can easily call webservice API methods.

Flask App

from jrpc.web import *
import jrpc.service
from flask import Flask, render_template

app = Flask(__name__)

class WebService(JRPCBlueprint):
    def __init__(self):
        JRPCBlueprint.__init__(self, "service", __name__, url_prefix="/api")

    @jrpc.service.method(path = "/echo/<name>")
    def echo(self, text, prefix = "Hello from", name = ""):
        return {"subject": prefix + " " + name, "message": text}


def index():
    return render_template("index.html")'', port=8080, debug=True)

Index.html Javascript

jrpc("/api").done(function(api) {
    api.echo({name: "Python JRPC", text: "Now with more Flask"}).done(function(result) {


{"subject":"Hello from Python JRPC", "message":"Now with more Flask"}

Why Use It?

Python-JRPC takes all of the boiler-plate code out of your network applications. Forget reading through socket documentation and developing your own message formats. All you need to do is write your Python server/client logic and let Python-JRPC handle the networking for you. Here's what you get: