IDRC
I Don't Really Care (IDRC): Auto APIs for lazy people
Table of Contents
Installation
IDRC can be installed via pip like so:
pip3 install idrc
Usage
IDRC can integrate with any function. For example:
from idrc import idrc
# Initialize the idrc class
api = idrc(verbose=True)
# Simulate a weather database
weather_data = {
"New York": {"temperature": 25, "condition": "Sunny"},
"Los Angeles": {"temperature": 30, "condition": "Cloudy"},
"Chicago": {"temperature": 18, "condition": "Rainy"}
}
# Define a weather forecast function
def get_weather(city: str) -> dict:
forecast = weather_data.get(city, None)
if forecast:
return forecast
else:
return api.ecode(404, 'City not found')
# Register the function as an API endpoint
api.define(get_weather, methods=['GET'])
# Run the idrc API
if __name__ == '__main__':
api.run(host='0.0.0.0', port=5000, debug=True)
The define function in the idrc library generated the api.
The Flask equivalent of the code above is:
from flask import Flask, request, jsonify
# Initialize the Flask app
app = Flask(__name__)
# Simulate a weather database
weather_data = {
"New York": {"temperature": 25, "condition": "Sunny"},
"Los Angeles": {"temperature": 30, "condition": "Cloudy"},
"Chicago": {"temperature": 18, "condition": "Rainy"}
}
# Define a weather forecast function
@app.route('/api/v1/get_weather', methods=['GET'])
def get_weather():
city = request.args.get('city')
if not city:
return jsonify({"error": "City parameter is required"}), 400
forecast = weather_data.get(city)
if forecast:
return jsonify(forecast)
else:
return jsonify({"error": "City not found"}),404
# Run the Flask app
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
IDRC condensed 27 lines of code into 25 lines of code, with much less typing overall.
IDRC vs Flask
Advantages of IDRC
- Rapid API development
- Very Simple
- Built-in error handling
- Lightweight wrapper of Flask
- Pretty terminal output
Advantages of Flask
- Mature framework
- Large community
- Flexible and extensible
- Extensive documentation
- Stack traces
Metadata
Release files for idrc 1.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| idrc-1.5.0.tar.gz | 9.2 kB | Without provenance | Details for idrc-1.5.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| idrc-1.5.0-py3-none-any.whl | Python 3 | none | any | Details for idrc-1.5.0-py3-none-any.whl |
Total release size: 19.3 kB
Release files / idrc-1.5.0.tar.gz
| Download URL | idrc-1.5.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
93f7b158fc9c844d2b11852172befd12be9e587333c363681ea9f66dcbc62005
|
|
BLAKE2b-256 checksum How to use checksums |
0b2f631af963b054965a3f0b41cf92b5ef31623cd1d0d153ea82e50fdf029349
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Release files / idrc-1.5.0-py3-none-any.whl
| Download URL | idrc-1.5.0-py3-none-any.whl |
|---|---|
| Size | 10.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ee6bef09f488b6afa78b340b308f06ae4cfc19116e16c9ea8f48b3aa0e0108ef
|
|
BLAKE2b-256 checksum How to use checksums |
dba18ba7ad1149ff4e3107ca71a1db25acf0e682af26d0de1d042ab8d6d87880
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.0.0 CPython/3.12.2
|
Security for idrc 1.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.