{"id":13771474,"url":"https://github.com/joeribekker/restorm","last_synced_at":"2025-08-29T13:09:52.885Z","repository":{"id":1848211,"uuid":"2772939","full_name":"joeribekker/restorm","owner":"joeribekker","description":"RestORM allows you to interact with resources as  if they were objects.","archived":false,"fork":false,"pushed_at":"2016-02-09T11:46:37.000Z","size":218,"stargazers_count":39,"open_issues_count":3,"forks_count":17,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-03-17T20:39:11.671Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"Icenium/sample-camera","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joeribekker.png","metadata":{"files":{"readme":"README.rst","changelog":"CHANGES.rst","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2011-11-14T15:23:21.000Z","updated_at":"2025-01-16T08:23:08.000Z","dependencies_parsed_at":"2022-08-20T11:00:29.849Z","dependency_job_id":null,"html_url":"https://github.com/joeribekker/restorm","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeribekker%2Frestorm","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeribekker%2Frestorm/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeribekker%2Frestorm/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeribekker%2Frestorm/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeribekker","download_url":"https://codeload.github.com/joeribekker/restorm/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244734070,"owners_count":20501014,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":"2024-08-03T17:00:51.892Z","updated_at":"2025-03-21T03:33:18.964Z","avatar_url":"https://github.com/joeribekker.png","language":"Python","funding_links":[],"categories":["ODM, ORM, Active Record"],"sub_categories":[],"readme":".. image:: https://secure.travis-ci.org/joeribekker/restorm.png?branch=master\n    :alt: Build Status\n    :target: http://travis-ci.org/joeribekker/restorm\n\nRestORM\n=======\n\nRestORM allows you to interact with resources as if they were objects (object\nrelational mapping), mock an entire API and incorporate custom client logic.\n\nDescription\n-----------\n\nRestORM structures the way you access a RESTful API and allows you to easily\naccess related resources. It tries to be as generic as possible so it's not\ntailored to any specific API or server-side API library. With RestORM you can\nmock an entire API and replace the real client with a mock version in unit\ntests. RestORM is very extensible but offers many functionalities out of the box\nto get you up and running quickly.\n\nCurrently, RestORM works on Python 2.5+ with Python 3 support on its way.\n\nFeatures\n--------\n\n* Object relational mapping of API resources (Django-like but does not depend on\n  Django at all).\n* Flexible client architecture that can be used with your own or third party\n  clients (like oauth).\n* Extensive mocking module allows you to mock API responses, or even \n  complete API's.\n* Examples for Twitter and Flickr API.\n\nQuick start\n===========\n\nThis is a compressed version of the tutorial. The full documentation can be \nfound `here \u003chttps://restorm.readthedocs.org\u003e`_.\n\nCreate a client\n---------------\n\nA typical client that can talk to a RESTful API using JSON, is no more then:\n\n.. sourcecode:: python\n\n    from restorm.clients.jsonclient import JSONClient\n    \n    client = JSONClient(root_uri='http://www.example.com/api/')\n    \nInstead of this client, we mock its intended behaviour.\n    \nCreate a mock API\n-----------------\n\nIn order to test your client, you can emulate a whole API using the\n``MockApiClient`` and add pre-defined responses.\n\nThe mock API below contains a list of books and a list of authors. To keep it \nsimple, both list resources contain only 1 item:\n\n.. sourcecode:: python\n\n    from restorm.clients.mockclient import MockApiClient\n    \n    mock_client = MockApiClient(\n        responses={\n            'book/': {'GET': ({'Status': 200}, [{'isbn': 1, 'title': 'Dive into Python', 'resource_url': 'http://www.example.com/api/book/1'}])},\n            'book/1': {'GET': ({'Status': 200}, {'isbn': 1, 'title': 'Dive into Python', 'author': 'http://www.example.com/api/author/1'})},\n            'author/': {'GET': ({'Status': 200}, [{'id': 1, 'name': 'Mark Pilgrim', 'resource_url': 'http://www.example.com/author/1'}])},\n            'author/1': {'GET': ({'Status': 200}, {'id': 1, 'name': 'Mark Pilgrim'})}\n        },\n        root_uri='http://www.example.com/api/'\n    )\n\nDefine resources\n----------------\n\nWe start with our main resource, the ``Book`` resource as a subclass of \n``Resource``. Two attributes in the inner ``Meta`` class indicate a URL-pattern\nhow we can access all books (``list``) and a single book (``item``):\n\n.. sourcecode:: python\n\n    from restorm.resource import Resource\n\n    class Book(Resource):\n        class Meta:\n            list = r'^book/$'\n            item = r'^book/(?P\u003cisbn\u003e\\d)$'\n\nBringing it all together\n------------------------\n\nYou can access the ``Book`` resource and the (runtime created) related \n``Author`` resource using the ``mock_client``:\n\n.. sourcecode:: python\n\n    \u003e\u003e\u003e book = Book.objects.get(isbn=1, client=mock_client) # Get book with ISBN number 1.\n    \u003e\u003e\u003e book.data['title'] # Get the value of the key \"name\".\n    u'Dive into Python'\n    \u003e\u003e\u003e book.data['author'] # Get the value of the key \"author\".\n    u'http://www.example.com/api/author/1'\n    \u003e\u003e\u003e author = book.data.author # Perform a GET on the \"author\" resource.\n    \u003e\u003e\u003e author.data['name']\n    u'Mark Pilgrim'\n\nInstallation\n============\n\nRestORM is on PyPI, so you can simply use::\n\n    $ pip install restorm\n\nIf you want the latest development version, get the code from Github::\n\n    $ pip install -e git+git://github.com/joeribekker/restorm.git#egg=restorm\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeribekker%2Frestorm","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeribekker%2Frestorm","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeribekker%2Frestorm/lists"}