Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/seven7ty/apico
Monitor changes in REST APIs with a few lines of code 🎈
https://github.com/seven7ty/apico
api api-rest http https python python3 rest-api
Last synced: 29 days ago
JSON representation
Monitor changes in REST APIs with a few lines of code 🎈
- Host: GitHub
- URL: https://github.com/seven7ty/apico
- Owner: seven7ty
- License: mit
- Created: 2021-02-01T21:37:07.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-01-26T11:46:01.000Z (almost 3 years ago)
- Last Synced: 2024-10-10T00:59:40.854Z (about 1 month ago)
- Topics: api, api-rest, http, https, python, python3, rest-api
- Language: Python
- Homepage: https://pypi.org/project/apico
- Size: 41 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
# apico [![Badge](https://img.shields.io/pypi/v/apico?color=3776AB&logo=python&style=for-the-badge)](https://pypi.org/project/apico/) [![Badge 2](https://img.shields.io/pypi/dm/apico?color=3776AB&logo=python&style=for-the-badge)](https://pypi.org/project/apico/)
*The easy way to monitor changes in RESTful APIs.*## Installation
```
$ pip install apico
```
## Example usage
```py
from apico import Monitor, Responsemonitor = Monitor(url='https://api.github.com/users/itsmewulf', rate=10.0, headers={'Authorization': 'GITHUB_TOKEN'})
@monitor.listener()
def on_change(old, new):
print('Something changed!')
@monitor.listener('no_change')
def nothing_changed():
print('Nothing changed!')
@monitor.listener()
def on_request():
print('This is called before every request.')
monitor.start()
```## Some reference
### Events
The events supported by the `Monitor.listener` decorator are:
- `change`
- `request`
- `no_change`As you can see in the example, listeners can be registered by passing the event name straight to the decorator (`monitor.listener('change')`) or inferred from the function name starting with `on_`:
```py
@monitor.listener()
def on_change(...):
```
### Monitor arguments
The monitor accepts a boatload of arguments, mainly ones that are then passed down to [`requests.Session.request()`](https://docs.python-requests.org/en/latest/api/#requests.Session.request), so, for a detailed insight follow the hyperlink or read the docstring.### Returns
The responses returned by apico are actually instances of [`requests.Response`](https://pypi.org/project/requests/)### Rate
The rate at which the Monitor sends requests is controlled via the `rate` parameter, which is either an integer, or a float - `33` is a request every 33 seconds, `0.5` is 2 requests every second._________________
## Reporting Issues
If you find any error/bug/mistake with the package or in the code feel free to create an issue and report
it [here.](https://github.com/itsmewulf/apico/issues)## Fix/Edit Content
If you wish to contribute to this package, fork the repository, make your changes and then simply create a Pull Request!