Science Score: 13.0%
This score indicates how likely this project is to be science-related based on various indicators:
-
○CITATION.cff file
-
✓codemeta.json file
Found codemeta.json file -
○.zenodo.json file
-
○DOI references
-
○Academic publication links
-
○Committers with academic emails
-
○Institutional organization owner
-
○JOSS paper metadata
-
○Scientific vocabulary similarity
Low similarity (9.0%) to scientific vocabulary
Keywords
Keywords from Contributors
Repository
REST API calls made easier
Basic Info
Statistics
- Stars: 16
- Watchers: 3
- Forks: 5
- Open Issues: 0
- Releases: 11
Topics
Metadata Files
README.md
RESTEasy
REST API calls made easier
Installation
bash
pip install resteasy
Usage and examples
Import
```python from resteasy import RESTEasy, json
api = RESTEasy(endpoint='https://api.example.com', auth=('user', '****'), verify=False, cert=None, timeout=None, allow_redirects=True, encoder=json.dumps, decoder=json.loads, debug=False)
optional timeout
api.timeout = 60 ```
Example 1: GitHub Jobs
```python api = RESTEasy(endpoint='https://jobs.github.com')
positions = api.route('positions.json')
positions.get(description='python', full_time=1)
or
positions.do('GET', {'description': 'python', 'full_time': 1})
GET https://jobs.github.com/positions.json?description=python&full_time=1
```
Example 2: All methods: GET, POST, PUT, PATCH, DELETE
```python from resteasy import RESTEasy
api = RESTEasy(endpoint='https://jsonplaceholder.typicode.com')
posts = api.route('posts')
GET (fetch resources)
posts.get() posts.get(userId=1) posts.route(1).get()
POST (create a resource)
posts.post(title='foo', body='bar', userId=1)
PUT & PATCH (update a resource)
posts.route(1).put(id=1, title='foo', body='bar', userId=1) posts.route(1).patch(title='foo')
DELETE (delete a resource)
posts.route(1).delete() ```
Example 3: Chuck Norris jokes
```python from future import print_function from resteasy import RESTEasy
api = RESTEasy(endpoint='https://api.chucknorris.io')
Print a random joke
jokes = api.route('jokes') random = jokes.route('random') print(random.get())
GET https://api.chucknorris.io/jokes/random
Get all categories
categories = jokes.route('categories').get() print(categories)
GET https://api.chucknorris.io/jokes/categories
Print a random joke from each category
for category in categories: randomjoke = random.get(category=category) print(category, ':', randomjoke['value'])
# GET https://api.chucknorris.io/jokes/random?category=<category>
```
Example 4: Using custom decoder: Parsing MyAnimeList HTML content
```python from resteasy import RESTEasy from html.parser import HTMLParser
class MyHTMLParser(HTMLParser): '''Custom HTML parser'''
def handle_starttag(self, tag, attrs):
'''Overriding abstract method'''
if tag == 'title' and not self.found:
self.found = True
def handle_data(self, data):
'''Overriding abstract method'''
if self.found and self.anime is None:
self.anime = data
def parse(self, content):
'''Parse content and return object'''
self.found = False
self.anime = None
self.feed(content)
title = self.anime.strip().replace(' - MyAnimeList.net', '') if self.found else None
return dict(title=title)
parser = MyHTMLParser()
api = RESTEasy(endpoint='https://myanimelist.net', decoder=parser.parse)
One way
api.route('anime/1').get()
Another way
api.route('anime', 1).get()
Yet another way
api.route('anime').route(1).get()
This is the last way I swear
api.route('anime').route(1).do(api.GET)
Just kidding...
api.route('anime').route(1).request(api.GET).json()
GET https://myanimelist.net/anime/1
```
Debugging
To enable debugging just pass or set debug=True
python
api.debug = True
Once debugging is set to 'True', Every HTTP call will return debug information instead of doing the actual request
```python
posts.debug = True posts.get(userId=1) {'endpoint': 'https://jsonplaceholder.typicode.com/posts', 'params': {'userId': 1}, 'method': 'GET', 'timeout': None} ```
Exceptions
- As this package uses requests module to perform HTTP calls, so all exceptions will be raised by requests module itself.
Owner
- Name: Arijit Basu
- Login: sayanarijit
- Kind: user
- Location: Kolkata, India
- Website: https://arijitbasu.in
- Repositories: 105
- Profile: https://github.com/sayanarijit
Just a ninja doing hand signs on a keyboard
GitHub Events
Total
- Watch event: 1
Last Year
- Watch event: 1
Committers
Last synced: about 2 years ago
Top Committers
| Name | Commits | |
|---|---|---|
| Arijit Basu | s****t@g****m | 32 |
| Arijit Basu | a****b@j****t | 1 |
| Arijit Basu | s****t | 1 |
| pyup-bot | g****t@p****o | 1 |
| dependabot-preview[bot] | 2****] | 1 |
Committer Domains (Top 20 + Academic)
Issues and Pull Requests
Last synced: 9 months ago
All Time
- Total issues: 1
- Total pull requests: 7
- Average time to close issues: 3 days
- Average time to close pull requests: about 2 months
- Total issue authors: 1
- Total pull request authors: 3
- Average comments per issue: 0.0
- Average comments per pull request: 0.43
- Merged pull requests: 6
- Bot issues: 1
- Bot pull requests: 1
Past Year
- Issues: 0
- Pull requests: 0
- Average time to close issues: N/A
- Average time to close pull requests: N/A
- Issue authors: 0
- Pull request authors: 0
- Average comments per issue: 0
- Average comments per pull request: 0
- Merged pull requests: 0
- Bot issues: 0
- Bot pull requests: 0
Top Authors
Issue Authors
- dependabot-preview[bot] (1)
Pull Request Authors
- sayanarijit (4)
- pyup-bot (2)
- dependabot-preview[bot] (1)
Top Labels
Issue Labels
Pull Request Labels
Dependencies
- requests *