{"id":17954432,"url":"https://github.com/sayanarijit/resteasy","last_synced_at":"2025-03-25T00:31:59.269Z","repository":{"id":52396909,"uuid":"124624438","full_name":"sayanarijit/RESTEasy","owner":"sayanarijit","description":"REST API calls made easier","archived":false,"fork":false,"pushed_at":"2024-06-22T04:33:05.000Z","size":40,"stargazers_count":15,"open_issues_count":0,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-19T06:01:57.576Z","etag":null,"topics":["api-client","http-client","json-api","python","requests","rest-api","rest-client"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sayanarijit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-10T05:13:48.000Z","updated_at":"2024-06-22T04:30:25.000Z","dependencies_parsed_at":"2024-10-29T10:38:03.364Z","dependency_job_id":null,"html_url":"https://github.com/sayanarijit/RESTEasy","commit_stats":{"total_commits":36,"total_committers":5,"mean_commits":7.2,"dds":"0.11111111111111116","last_synced_commit":"591107e150e989208850459de60a5b9ff29b66bd"},"previous_names":["rapidstack/resteasy"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayanarijit%2FRESTEasy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayanarijit%2FRESTEasy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayanarijit%2FRESTEasy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sayanarijit%2FRESTEasy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sayanarijit","download_url":"https://codeload.github.com/sayanarijit/RESTEasy/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245377921,"owners_count":20605374,"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":["api-client","http-client","json-api","python","requests","rest-api","rest-client"],"created_at":"2024-10-29T10:16:26.828Z","updated_at":"2025-03-25T00:31:58.833Z","avatar_url":"https://github.com/sayanarijit.png","language":"Python","readme":"# RESTEasy\n\nREST API calls made easier\n\n[![PyPI version](https://img.shields.io/pypi/v/resteasy.svg)](https://pypi.org/project/resteasy)\n[![Python versions](https://img.shields.io/pypi/pyversions/resteasy.svg)](https://pypi.org/project/resteasy)\n[![Build status](https://travis-ci.org/sayanarijit/resteasy.svg?branch=master)](https://travis-ci.org/sayanarijit/resteasy)\n[![Code coverage](https://codecov.io/gh/sayanarijit/resteasy/branch/master/graph/badge.svg)](https://codecov.io/gh/sayanarijit/resteasy)\n\n- [RESTEasy](#resteasy)\n    - [Installation](#installation)\n    - [Usage and examples](#usage-and-examples)\n        - [Import](#import)\n        - [Example 1: GitHub Jobs](#example-1-github-jobs)\n        - [Example 2: All methods: GET, POST, PUT, PATCH, DELETE](#example-2-all-methods-get-post-put-patch-delete)\n        - [Example 3: Chuck Norris jokes](#example-3-chuck-norris-jokes)\n        - [Example 4: Using custom decoder: Parsing MyAnimeList HTML content](#example-4-using-custom-decoder-parsing-myanimelist-html-content)\n    - [Debugging](#debugging)\n    - [Exceptions](#exceptions)\n\n## Installation\n\n```bash\npip install resteasy\n```\n\n## Usage and examples\n\n### Import\n\n```python\nfrom resteasy import RESTEasy, json\n\napi = RESTEasy(endpoint='https://api.example.com',\n               auth=('user', '****'),\n               verify=False, cert=None, timeout=None,\n               allow_redirects=True,\n               encoder=json.dumps, decoder=json.loads, debug=False)\n               \n# optional timeout\napi.timeout = 60\n```\n\n### Example 1: GitHub Jobs\n\n```python\napi =  RESTEasy(endpoint='https://jobs.github.com')\n\npositions = api.route('positions.json')\n\npositions.get(description='python', full_time=1)\n# or\npositions.do('GET', {'description': 'python', 'full_time': 1})\n\n# GET https://jobs.github.com/positions.json?description=python\u0026full_time=1\n```\n\n### Example 2: All methods: GET, POST, PUT, PATCH, DELETE\n\n```python\nfrom resteasy import RESTEasy\n\napi = RESTEasy(endpoint='https://jsonplaceholder.typicode.com')\n\nposts = api.route('posts')\n\n### GET (fetch resources)\nposts.get()\nposts.get(userId=1)\nposts.route(1).get()\n\n### POST (create a resource)\nposts.post(title='foo', body='bar', userId=1)\n\n### PUT \u0026 PATCH (update a resource)\nposts.route(1).put(id=1, title='foo', body='bar', userId=1)\nposts.route(1).patch(title='foo')\n\n### DELETE (delete a resource)\nposts.route(1).delete()\n```\n\n### Example 3: Chuck Norris jokes\n\n```python\nfrom __future__ import print_function\nfrom resteasy import RESTEasy\n\napi = RESTEasy(endpoint='https://api.chucknorris.io')\n\n\n### Print a random joke\njokes = api.route('jokes')\nrandom = jokes.route('random')\nprint(random.get())\n\n# GET https://api.chucknorris.io/jokes/random\n\n\n### Get all categories\ncategories = jokes.route('categories').get()\nprint(categories)\n\n# GET https://api.chucknorris.io/jokes/categories\n\n\n### Print a random joke from each category\nfor category in categories:\n    random_joke = random.get(category=category)\n    print(category, ':', random_joke['value'])\n\n    # GET https://api.chucknorris.io/jokes/random?category=\u003ccategory\u003e\n```\n\n### Example 4: Using custom decoder: Parsing MyAnimeList HTML content\n\n```python\nfrom resteasy import RESTEasy\nfrom html.parser import HTMLParser\n\nclass MyHTMLParser(HTMLParser):\n    '''Custom HTML parser'''\n    \n    def handle_starttag(self, tag, attrs):\n        '''Overriding abstract method'''\n        if tag == 'title' and not self.found:\n            self.found = True\n\n    def handle_data(self, data):\n        '''Overriding abstract method'''\n        if self.found and self.anime is None:\n            self.anime = data\n    \n    def parse(self, content):\n        '''Parse content and return object'''\n        self.found = False\n        self.anime = None\n        self.feed(content)\n        title = self.anime.strip().replace(' - MyAnimeList.net', '') if self.found else None\n        return dict(title=title)\n\nparser = MyHTMLParser()\n\napi = RESTEasy(endpoint='https://myanimelist.net', decoder=parser.parse)\n\n### One way\napi.route('anime/1').get()\n\n### Another way\napi.route('anime', 1).get()\n\n### Yet another way\napi.route('anime').route(1).get()\n\n### This is the last way I swear\napi.route('anime').route(1).do(api.GET)\n\n### Just kidding...\napi.route('anime').route(1).request(api.GET).json()\n\n# GET https://myanimelist.net/anime/1\n```\n\n## Debugging\n\nTo enable debugging just pass or set ***debug=True***\n\n```python\napi.debug = True\n```\n\nOnce debugging is set to 'True', Every HTTP call will return debug information instead of doing the actual request\n\n```python\n\u003e\u003e\u003e posts.debug = True\n\u003e\u003e\u003e posts.get(userId=1)\n{'endpoint': 'https://jsonplaceholder.typicode.com/posts',\n 'params': {'userId': 1},\n 'method': 'GET',\n 'timeout': None}\n```\n\n## Exceptions\n\n* As this package uses requests module to perform HTTP calls, so all exceptions will be raised by requests module itself.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayanarijit%2Fresteasy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsayanarijit%2Fresteasy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsayanarijit%2Fresteasy/lists"}