npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

pyconnector

v1.0.3

Published

Bridge the gap between Node.JS and Python applications

Downloads

93

Readme

PyConnector

pyconnector: Bridge the gap between Node.JS and Python applications

Both Node.JS and Python have their own unique strengths and weaknesses when it comes to developing applications. This module provides a simple and crude interface to embed and use Python code for number crunching queries.

Installation

Just type npm install pyconnector and you are ready to go.

Usage

Node.JS

Create a new instance of PyConnector class having the desired options.

// minimal.js
const Path = require('path')
const PyConnector = require('pyconnector')

// create connector
var PyAPI = new PyConnector({
  // local port or remote IP:Port string '192.168.0.12:9000'
  endpoint: 24001,
  // pass null or remove option to prevent spawning a child process
  path: Path.join(__dirname, 'minimal.py')
});

// query python resolvers
(async function () {
  console.log('Available Python routes:', await PyAPI.routes())
  console.log('Python version:', await PyAPI.query('pyversion'))
  console.log('Increment ++', await PyAPI.query('increment'))
  console.log('Increment ++', await PyAPI.query('increment', { pass_var: 13 }))

  // kill python process
  PyAPI.end()
})()

Python

Install Python dependencies

pip install nodeconnector argparse

Create minimal.py file

# minimal.py
import sys
import time
import argparse
import nodeconnector

# argument parsing, PyConnector automatically sends this
parser = argparse.ArgumentParser( description = 'Python Exposed API' )
parser.add_argument( '--pynodeport', help = 'PyConnector Node.JS query port', default = 24001 )
args = parser.parse_args()

# create interface
nodeq = nodeconnector.Interface( )

# python version query
def nodeq_version( args, ctx = {} ):
    return ( '%d.%d.%d' % ( sys.version_info[ 0 ], sys.version_info[ 1 ], sys.version_info[ 2 ] ) )

# increment value query
def nodeq_increment( args, ctx = {} ):
    # return value
    ctx[ 'inc' ] += 1
    args[ 'value' ] = ctx[ 'inc' ]

    return args

# queries are executed on a separate thread, a context dict can be used to pass data
nodeq.handle( 'pyversion', nodeq_version )
nodeq.handle( 'increment', nodeq_increment, dict( inc = 0 ) ) 

# launch API
nodeq.listen( port = args.pynodeport ) 

# wait
while( True ):
    time.sleep( 0.001 )

Background

PyConnector is intended to be used for rapid prototyping within POC applications. For production and advanced use cases, its recommended to use this ZeroMQ package, which this module heavily relies upon.

License (MIT)

Copyright (C) 2019 Cristian Dobre