{ "info": { "author": "Namlook", "author_email": "UNKNOWN", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Other Environment", "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Software Development :: Libraries :: Python Modules", "Topic :: Utilities" ], "description": "ApiBee\n======\n\nApiBee is a dynamic rest client built on top of the excellent restkit_ library.\n\n.. _restkit : http://github.com/benoitc/restkit\n\nIt aims to be able to handle any uris for any apis.\n\nHow it work ?\n-------------\n\nLet's say we want to fetch the json API of the great service http://www.example.com. Their api is served from http://api.example.com/1.0/::\n\n >>> from apibee import Client\n >>> api = Client('http://api.example.com/1.0/')\n\nNow we want to get the result from http://api.example.com/1.0/users/search?q=Timy::\n\n >>> results = api.users.search(q='Timy')\n\nThat's it !\n\nGoing further\n-------------\n\nGetting json result\n+++++++++++++++++++\n\nHere::\n\n class ExampleClient(Client):\n def process_result(self, result):\n return json.loads(result)\n\nNow the result is a python type::\n\n >>> api = ExampleClient(\"http://api.example.com/1.0/\")\n >>> result = api.user.search(q=\"timy\")\n\nAdding query automatically\n++++++++++++++++++++++++++\n\nSometimes some api are a bit tricky. And we need to build a custom client to match thoses. \n\nPreviously, the version of the api was part of the resource but what if we have to specify it for each request::\n\n http://api.example.com/user/search?v=1.0&q=Timy\n\nWe can specify one or more params which will be automatically add to the query::\n\n class ExampleClient(Client):\n def set_persistent_query(**args):\n self._persistent_query = args\n\n def build_query(self, response, query):\n query.update(self._persistent_query)\n return response, query\n\n >>> api = ExampleClient('http://api.example.com')\n >>> api.set_persistent_query(v=\"1.0\")\n\n\nCustomize resources\n+++++++++++++++++++\n\nSome apis like Twitter add `.json` after the resource but before the query : https://api.twitter.com/1/search.json&q=Timy. We can do it like this::\n\n class TwitterClient(Client):\n def set_format(self, f):\n self._format = f\n\n def build_query(self, response, query):\n response = \"%s.%s\" % (response, self._format)\n return response, query\n\n >>> api = TwitterClient('https://api.twitter.com/1', end_resource='.json')\n >>> results = api.search(q='Timy')\n\nRaising errors\n++++++++++++++\n\nSometimes you may have to clean up the result before send it back. You can do it by overloading the `Client.process_result` method.\n\nExample:\n\n Google's web service won't send an http error 400 if the request failed. Instead, it will send a custom result::\n\n http://ajax.googleapis.com/ajax/services/search/web?q=Earth%20Day\n\nwill send back::\n\n {\"responseData\": null, \"responseDetails\": \"invalid version\", \"responseStatus\": 400}\n\nLet's say we want to catch the error and raise an RequestFailed exception with a custom message which is in the \"responseDetails\" field::\n\n class GoogleClient(Client):\n def process_result(self, result):\n if result[\"responseStatus\"] == 400:\n raise RequestFailed(result['responseDetails'])\n return result\n\nThat's it ! Don't forget to return the result at the end of the `process_result` method.\n\n >>> api = GoogleClient('http://ajax.googleapis.com/ajax/services')\n >>> api.search.web(q=\"toto\")\n Traceback (most recent call last):\n ...\n RequestFailed: invalid version", "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/namlook/apibee", "keywords": null, "license": "New BSD License", "maintainer": null, "maintainer_email": null, "name": "apibee", "package_url": "https://pypi.org/project/apibee/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/apibee/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/namlook/apibee" }, "release_url": "https://pypi.org/project/apibee/0.2.2/", "requires_dist": null, "requires_python": null, "summary": "A dynamic api client", "version": "0.2.2" }, "last_serial": 786327, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "1629bb4a72a88359152588f71ed82e65", "sha256": "6f5cd76fa1548579cccb7b14ba9774c5a8509b958184c7d4d8f392da17335e4b" }, "downloads": -1, "filename": "apibee-0.1.tar.gz", "has_sig": false, "md5_digest": "1629bb4a72a88359152588f71ed82e65", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 85816, "upload_time": "2011-09-05T15:04:46", "url": "https://files.pythonhosted.org/packages/3a/9d/a367b50ab41b720c9d33aa53ca4fca0fd8a61bc0ffb801fe05a7bce4b5bd/apibee-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "819ef2269ec7f92da214313a05e0b30f", "sha256": "ff3a764162037b0be23aed4ace647e4ee4f154263c6b55ae60c0288edbcca37e" }, "downloads": -1, "filename": "apibee-0.2.tar.gz", "has_sig": false, "md5_digest": "819ef2269ec7f92da214313a05e0b30f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 85850, "upload_time": "2011-09-23T15:29:29", "url": "https://files.pythonhosted.org/packages/b8/d2/77eb90a195c40cf0bd228c65b255d5388d18108d491133a2e8be6aa1b3a1/apibee-0.2.tar.gz" } ], "0.2.2": [ { "comment_text": "", "digests": { "md5": "d6a8f1ca4a4dd630b39866593fda1275", "sha256": "aa20288a8de63e30822fa85c15306f22a8e9a68614c45e85a76c9db66361a821" }, "downloads": -1, "filename": "apibee-0.2.2.tar.gz", "has_sig": false, "md5_digest": "d6a8f1ca4a4dd630b39866593fda1275", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 37555, "upload_time": "2012-01-19T10:13:25", "url": "https://files.pythonhosted.org/packages/55/61/bcd301aeed4e9a8ee699d9a679a3bb6ca12effc79be8dcf0ab4f00819543/apibee-0.2.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "d6a8f1ca4a4dd630b39866593fda1275", "sha256": "aa20288a8de63e30822fa85c15306f22a8e9a68614c45e85a76c9db66361a821" }, "downloads": -1, "filename": "apibee-0.2.2.tar.gz", "has_sig": false, "md5_digest": "d6a8f1ca4a4dd630b39866593fda1275", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 37555, "upload_time": "2012-01-19T10:13:25", "url": "https://files.pythonhosted.org/packages/55/61/bcd301aeed4e9a8ee699d9a679a3bb6ca12effc79be8dcf0ab4f00819543/apibee-0.2.2.tar.gz" } ] }