Skip to main content
Join the official 2019 Python Developers SurveyStart the survey! wrapper to make python objects accessible via HTTP API

Project description


A simple to provide HTTP API access to any python object.


Quick Start

Install with

pip install APyI

Create your API with

from PyAPI import API

myapi = API()

You can pass a port number with port=42, a path with path="api" and whether you want to serve on IPv4 (IPv6=False). You can also give the API object an existing bottle server (server=bottleobject), in which case your API will be served on the existing server. In this case, it is heavily recommended to pass a path variable to separate API from regular routing of your server.

Then make any class accessible with a decorator.

class Group:

	def __init__(self,name,apipath,songs):
		# some stuff
		self.__apiname__ = apipath

Any instance of that class is now accessible via the combination of class path and its individual path. Now just decorate the methods. All its arguments can be passed via URI query arguments.

	def get_songs(self,member):
		return {"songs":[s["title"] for s in self.songs if member in s["performers"]]}

Now create an object and make sure it has an __apiname__ attribute:

e = Group("Exid","exid",exidsongs)

Then you can access its methods with simple HTTP calls:

HTTP GET http://localhost:1337/group/exid/songs?member=Junghwa

Project details

Download files

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

Files for APyI, version 0.1.1
Filename, size File type Python version Upload date Hashes
Filename, size APyI-0.1.1-py3-none-any.whl (16.0 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size APyI-0.1.1.tar.gz (3.4 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page