{ "info": { "author": "Florian Schlachter", "author_email": "flori@n-schlachter.de", "bugtrack_url": null, "classifiers": [ "Development Status :: 3 - Alpha", "Environment :: Web Environment", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent", "Programming Language :: Python" ], "description": "=========\nsimpleapi\n=========\n\n:version: 0.0.9\n:author: Florian Schlachter (http://www.fs-tools.de)\n:license: MIT-license / see LICENSE file for more\n:website: http://simpleapi.florian-schlachter.de\n:mailinglist: subscribe: simpleapi@librelist.com\n\nAn almost complete documentation is still work in progress and will be published at http://simpleapi.florian-schlachter.de soon.\n\nAbout\n=====\n\nsimpleapi is an **easy to use, consistent, transparent and portable** way of\nproviding an API. It supports **several transport formats** (e. g. json, jsonp,\nxml, yaml) and provides **server** (standalone and also django, Flask, Google AppEngine and any WSGI-compatible implementation like gunicorn) and **client libraries** (PHP, Python) to interact seamlessly. You can also use nearly every **Ajax framework** (e. g. jQuery, ExtJS, etc.) to access the API.\n\n* server support for **django**, **Flask** and **Google AppEngine**\n* client support for **python**, **php** and **javascript**\n* dynamic key authentication / ip restriction\n* type-conversion / constraints\n* object serialization of django model instances, django queryset instances, \n mongoengine documents, mongoengine queryset instances\n* inheritance / multiple versions of one API\n* several encoding/decoding formats (json, jsonp, xml, yaml, etc.)\n* several result formats (ie. for ExtJS forms, etc.)\n* features: caching, throttling\n* debugging and profiling capabilities\n* examples\n\nInstallation\n============\n\n::\n \n pip install --upgrade simpleapi\n\nFrom GitHub\n-----------\n\n::\n \n git clone git://github.com/flosch/simpleapi.git\n\nDependencies\n============\n\n* **server**: django >= 1.1.1, Flask >= 0.1 or Google AppEngine\n* Python 2.5 or greater\n* simplejson (if you're using Python <= 2.5)\n* python-dateutil\n* pyyaml (optional, for YAML-support)\n* sphinx (optional, for the docs)\n\n(see requirements.txt as well)\n\nExamples\n========\n\nSMS-System\n----------\n\nServer (handler.py)::\n\n from simpleapi import Namespace, serialize\n from models import SMS, APIUser\n \n class SMSAPI(Namespace):\n __authentication__ = lambda namespace, access_key: \\\n APIUser.objects.filter(access_key=access_key).count() > 0\n\n def send(self, to, msg, from='testsender'):\n sms = SMS.objects.create(\n to=to\n msg=msg,\n from=from\n )\n return {\n 'sent': sms.send(),\n 'obj': serialize(sms, excludes=[re.compile('^date'),])\n }\n send.published = True\n send.constraints = {'to': re.compile(r'^\\+\\d{2,}\\ \\d{3,}\\ \\d{5,}')}\n \n def status(self, id):\n return SMS.objects.get(id=id)\n status.published = True\n status.constraints = {'id': int}\n \n def last(self, numbers=5):\n return SMS.objects.all()[:numbers]\n last.published = True\n last.constraints = {'numbers': int}\n\n**Standalone-Server** (app.py)::\n\n from simpleapi import Route\n from handlers import SMSAPI\n\n route = Route(SMSAPI, framework='standalone', path=r'^/api/')\n route.serve() # serves on port 5050 by default\n\nGunicorn (**WSGI-compatible implementation**) (app.py)::\n\n from simpleapi import Route\n from handlers import SMSAPI\n\n route = Route(SMSAPI, framework='wsgi', path=r'^/api/')\n \n # start Gunicorn (with 5 workers):\n # gunicorn -w 5 app:route\n\n**Django-Server** (urls.py)::\n\n from handlers import SMSAPI\n urlpatterns = patterns('',\n (r'^api/$', Route(SMSAPI))\n )\n\n**Flask-Server** (app.py)::\n\n from flask import Flask\n from simpleapi import Route\n from handlers import SMSAPI\n\n app = Flask(__name__)\n app.route('/api/')(Route(SMSAPI, framework='flask'))\n\n if __name__ == '__main__':\n app.run()\n\n**Google AppEngine** (main.py)::\n\n from google.appengine.ext import webapp\n from google.appengine.ext.webapp import util\n\n from simpleapi import Route\n from handlers import SMSAPI\n\n def main():\n application = webapp.WSGIApplication(\n [('/api/', Route(SMSAPI, framework='appengine'))]\n )\n util.run_wsgi_app(application)\n\n if __name__ == '__main__':\n main()\n\nClient (python/**remote**)::\n\n from simpleapi import Client\n \n client = Client(ns='http://remote.tld:8888/api/', access_key='mysecret',\n transport_type='xml')\n \n sms = client.sms(to='555123', msg='Hey yo! This is simpleapi calling.')\n print \"Sent successful?\", sms['sent']\n \n sms = client.sms(to='555123', msg='2nd test with own sender',\n sender='simpleapi')\n print \"Sent successful?\", sms['sent']\n print \"Which sender?\", sms['obj']['sender']\n\nClient (python/**local**)::\n\n from simpleapi import DummyClient, Route\n from handlers import SMSAPI\n \n client = DummyClient(Route(SMSAPI, framework='dummy'),\n access_key='mysecret')\n \n sms = client.sms(to='555123', msg='Hey yo! This is simpleapi calling.')\n print \"Sent successful?\", sms['sent']\n \n sms = client.sms(to='555123', msg='2nd test with own sender',\n sender='simpleapi')\n print \"Sent successful?\", sms['sent']\n print \"Which sender?\", sms['obj']['sender']\n\nClient (PHP)::\n\n require_once(\"class.client.php\");\n \n $client = new Client($ns=\"http://localhost:8888/api/\",\n $access_key='mysecret');\n print(\"Sent? \".$client->sms(array(\n 'to' => '555123',\n 'msg' => 'Hey yo! This is the PHP client sending you a SMS.'\n ))->{'sent'});\n\nClient (jQuery)::\n\n jQuery.get(\n \"/api/\",\n {_call: 'send', to: '555123', 'msg': 'Hey ya!'},\n function (return) {\n if (return.result.sent)\n alert('Sent successfully!');\n else\n alert('Sending failed!');\n }\n )\n\nCalculator\n----------\n\nServer (handler.py)::\n\n from simpleapi import Namespace\n \n class CalculatorAPI(Namespace):\n __ip_restriction__ = ['127.0.0.*',]\n __authentication__ = \"lets_calc\"\n \n def power(self, a, b):\n return a ** b\n power.published = True\n power.constraints = lambda namespace, key, value: float(value)\n \n def sum(self, **kwargs)\n return sum(kwargs.values())\n sum.published = True\n sum.constraints = lambda namespace, key, value: float(value)\n\n**Standalone-Server** (app.py)::\n\n from simpleapi import Route\n from handlers import CalculatorAPI\n\n route = Route(CalculatorAPI, framework='standalone', path=r'^/api/')\n route.serve() # serves on port 5050 by default\n\nGunicorn (**WSGI-compatible implementation**) (app.py)::\n\n from simpleapi import Route\n from handlers import CalculatorAPI\n\n route = Route(CalculatorAPI, framework='wsgi', path=r'^/api/')\n \n # start Gunicorn (with 5 workers):\n # gunicorn -w 5 app:route\n\n**Django-Server** (urls.py)::\n\n from handlers import CalculatorAPI\n urlpatterns = patterns('',\n (r'^api/$', Route(CalculatorAPI))\n )\n\n**Flask-Server** (app.py)::\n\n from flask import Flask\n from simpleapi import Route\n from handlers import CalculatorAPI\n\n app = Flask(__name__)\n app.route('/api/')(Route(CalculatorAPI, framework='flask'))\n\n if __name__ == '__main__':\n app.run()\n\n**Google AppEngine** (main.py)::\n\n from google.appengine.ext import webapp\n from google.appengine.ext.webapp import util\n\n from simpleapi import Route\n from handlers import CalculatorAPI\n\n def main():\n application = webapp.WSGIApplication(\n [('/api/', Route(CalculatorAPI, framework='appengine'))]\n )\n util.run_wsgi_app(application)\n\n if __name__ == '__main__':\n main()\n\nClient (python/**remote**)::\n\n from simpleapi import Client\n \n client = Client(ns='http://remote.tld:8888/api/', access_key='lets_calc')\n \n print \"5 ** 8 =\", client.power(a=5, b=8)\n print \"1+2+3+4+5+6+7 =\", client.sum(a=1, b=2, c=3, d=4, e=5, f=6, g=7)\n\nClient (python/**local**)::\n\n from simpleapi import DummyClient, Route\n from handlers import CalculatorAPI\n \n client = DummyClient(Route(CalculatorAPI, framework='dummy'),\n access_key='lets_calc')\n \n print \"5 ** 8 =\", client.power(a=5, b=8)\n print \"1+2+3+4+5+6+7 =\", client.sum(a=1, b=2, c=3, d=4, e=5, f=6, g=7)\n\nClient (PHP)::\n\n require_once(\"class.client.php\");\n \n $client = new Client($ns=\"http://localhost:8888/api/\",\n $access_key='lets_calc');\n print(\"5 ** 8 = \".$client->power(array('a'=>5, 'b'=>8)));\n\nClient (jQuery)::\n\n jQuery.get(\n \"/api/\",\n {_call: 'power', a: 5, b: 8, _access_key: \"lets_calc\"},\n function (return) {\n alert('5 ** 8 = ' + return.result)\n }\n )", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/flosch/simpleapi/tree/", "keywords": null, "license": "UNKNOWN", "maintainer": null, "maintainer_email": null, "name": "simpleapi", "package_url": "https://pypi.org/project/simpleapi/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/simpleapi/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/flosch/simpleapi/tree/" }, "release_url": "https://pypi.org/project/simpleapi/0.0.9/", "requires_dist": null, "requires_python": null, "summary": "A simple API-framework to provide an easy to use, consistent and portable client/server-architecture (for django, flask and a lot more).", "version": "0.0.9" }, "last_serial": 799565, "releases": { "0.0.7": [ { "comment_text": "", "digests": { "md5": "146be62939960b730684ccd14d9e1506", "sha256": "cf29ee23ec7f9cd7cc0fcb0829a3d2b4be1e54117d0c65f230f56e11d0564d36" }, "downloads": -1, "filename": "simpleapi-0.0.7.tar.gz", "has_sig": false, "md5_digest": "146be62939960b730684ccd14d9e1506", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 24443, "upload_time": "2010-05-30T20:28:20", "url": "https://files.pythonhosted.org/packages/07/83/6771fcecc42c0e633d7421ef468c7ee1ea8619871ba4e62a7bfc29cda36d/simpleapi-0.0.7.tar.gz" } ], "0.0.8": [ { "comment_text": "", "digests": { "md5": "c6ca940256366aefae8bcb81feae8472", "sha256": "c42617dc8b31c5f211b091a6b3bea98e56d1b4ca3c2d454b11c389322a0be1a2" }, "downloads": -1, "filename": "simpleapi-0.0.8.tar.gz", "has_sig": false, "md5_digest": "c6ca940256366aefae8bcb81feae8472", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 27886, "upload_time": "2010-06-14T01:28:53", "url": "https://files.pythonhosted.org/packages/94/38/0789c22fba22198f0f0e618621f99cedeb179f8e3250c7b5c874c60bcaef/simpleapi-0.0.8.tar.gz" } ], "0.0.9": [ { "comment_text": "", "digests": { "md5": "cc32dd557e3079bbc1efc0be950082f4", "sha256": "ea5b9a76bce0f7ef77c67b4ba387da24d1abf15f1983b2fbac458c65fd10190b" }, "downloads": -1, "filename": "simpleapi-0.0.9.tar.gz", "has_sig": false, "md5_digest": "cc32dd557e3079bbc1efc0be950082f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28166, "upload_time": "2012-03-29T02:40:18", "url": "https://files.pythonhosted.org/packages/f0/e1/e74116165c28e5f7c3b4d6c0bdf677d52526ba3a64af324cf596819be951/simpleapi-0.0.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "cc32dd557e3079bbc1efc0be950082f4", "sha256": "ea5b9a76bce0f7ef77c67b4ba387da24d1abf15f1983b2fbac458c65fd10190b" }, "downloads": -1, "filename": "simpleapi-0.0.9.tar.gz", "has_sig": false, "md5_digest": "cc32dd557e3079bbc1efc0be950082f4", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 28166, "upload_time": "2012-03-29T02:40:18", "url": "https://files.pythonhosted.org/packages/f0/e1/e74116165c28e5f7c3b4d6c0bdf677d52526ba3a64af324cf596819be951/simpleapi-0.0.9.tar.gz" } ] }