{"id":34719871,"url":"https://github.com/explodes/ezrest","last_synced_at":"2026-05-24T01:32:33.789Z","repository":{"id":3593179,"uuid":"4657026","full_name":"explodes/ezrest","owner":"explodes","description":"Python REST super layer.","archived":false,"fork":false,"pushed_at":"2012-06-15T16:50:51.000Z","size":120,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-12-26T12:55:08.878Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/explodes.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-13T22:50:21.000Z","updated_at":"2015-03-29T09:10:18.000Z","dependencies_parsed_at":"2022-09-10T22:11:40.164Z","dependency_job_id":null,"html_url":"https://github.com/explodes/ezrest","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/explodes/ezrest","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodes%2Fezrest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodes%2Fezrest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodes%2Fezrest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodes%2Fezrest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/explodes","download_url":"https://codeload.github.com/explodes/ezrest/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/explodes%2Fezrest/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33418547,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T22:14:44.296Z","status":"ssl_error","status_checked_at":"2026-05-23T22:14:43.778Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-25T01:43:32.997Z","updated_at":"2026-05-24T01:32:33.776Z","avatar_url":"https://github.com/explodes.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"======================================\n`ezrest` Python REST wrapper framework\n======================================\n\n**Project Goal**\n\nThis goal of this project is to supply a framework that makes writing REST API wrappers much faster.\n\n**Code Goal**\n\nEnsuring extensibility is the most important part. There are a million different API's and they are ALL different.\nIn no way will it be possible to make a framework that can wrap all API's. This framework will target API's that\nconform to the most BASIC of REST protocols while supplying addons that conform the most advanced.\n\n:Basic Features:\n   The most basic features include CRUD.\n\n:Advanced:\n    The most advanced feature include different actions based on HTTP response codes.\n\nREADME CONTENTS\n---------------\n\n:Package Contents:\n    A summary of the package and the modules within\n\n:Example Usage:\n    A basic example used to search google\n\nPACKAGE CONTENTS\n----------------\n\n:`example`:\n    Contains examples.\n\n:`example.google`:\n    An example app for querying google, written intentionally complicated to demonstrate proper OOP techniques.\n\n:`ezrest`:\n    The framework layer\n\n:`ezrest.model`:\n    Base Model class and Metaclass details\n\n:`ezrest.parameter`:\n    Parameter class and subclasses.\n\n:`ezrest.host`:\n    Contains the simplest HostController. You can subclass it to suit your needs, or use it right out of the box. \n\n:`ezrest.exceptions`:\n    Exception objects used in the app. All exceptions thrown must extend EZRestError.\n\n:`tests`:\n    Unit tests\n\nEXAMPLE USAGE\n-------------\n\nThis example uses REST to query Google under the /search controller.\n\nThis could all be replaced with\n\n``urllib.urlopen('http://google.com/search?q=ezrest').read().count('ezrest')``\n\n(Except that Google doesn't like requests from unknown clients, the appropriate headers are added below)\n\n::\n\n    from ezrest import host, model, parameter\n    \n    class ResponseModel(model.Model):\n        ''' Model built to handle a response itself '''\n        def response(self, response):\n            print 'TODO: Handle the response'\n    \n    class GoogleHostController(host.HostController):\n    \n        def __init__(self):\n            ''' Shortcut for init, simply init with google as our host destination '''\n            super(GoogleHostController, self).__init__('http://www.google.com')\n    \n        def handle_response(self, instance, response):\n            ''' Use our ResponseModels to handle the responses '''\n            if isinstance(instance, ResponseModel):\n                instance.response(response)\n            return super(GoogleHostController, self).handle_response(instance, response)\n    \n        def get_request_headers(self, method, url, get_data=None, post_data=None, instance=None):\n            ''' Build request headers to simulate a request from Firefox '''\n            d = super(GoogleHostController, self).get_request_headers(method, url, get_data=get_data, post_data=post_data, instance=instance)\n            d['User-agent'] = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:13.0) Gecko/20100101 Firefox/13.0'\n            d['Accept'] = 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8'\n            return d\n    \n    class GoogleSearch(ResponseModel):\n    \n        query = parameter.TextParameter(remote_name='q', read=True)\n        occurrences_of_the_word_ezrest = parameter.IntegerParameter()\n    \n        class Meta:\n            controller = '/search'\n    \n        def __init__(self, query):\n            self.query = query\n    \n        def response(self, response):\n            self.occurrences_of_the_word_ezrest = response.read().count('ezrest')\n    \n    if __name__ == '__main__':\n        ghc = GoogleHostController()\n        search = GoogleSearch('ezrest')\n        ghc.read(search) # updates the search with the faux results after the response is received\n        print search.parameters('occurrences_of_the_word_ezrest').to_get() # Serialize our results for the fun of it\n        print search.occurrences_of_the_word_ezrest                        # Print out the value updated from the response\n\n    $python testcase.py\n    occurrences_of_the_word_ezrest=88\n    88\n\nThe concept here is that you can create a model and supply attributes that get sent out with the requests.\n\nAfter a Host is set up, it is just a matter of creating models.\n\nNotice in GoogleSearch,\n\n``query = parameter.TextParameter(remote_name='q', read=True)``\n\nThis could be rewritten as:\n\n``q = parameter.TextParameter(read=True)``\n\nBut in the interest of legibility, the `local_name` is `query.`\n\nIn other models, we could have attributes like:\n\n``id = parameter.IntegerParameter(read=True, create=True, update=True, delete=True)``\n\nWhich indicates that the parameter is to be send out with all of those host request types.\n\n``occurrences_of_the_word_ezrest = parameter.IntegerParameter()`` is a plain parameter. Since it is not used in the API, we could have simply made it an instance variable.  However, ``print search.parameters('occurrences_of_the_word_ezrest').to_get()`` would then not print out serialized attributes and we wouldn't have had as much fun as we did!\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexplodes%2Fezrest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fexplodes%2Fezrest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fexplodes%2Fezrest/lists"}