https://github.com/santalvarez/python-rule-engine
A rule engine where rules are defined in JSON format
https://github.com/santalvarez/python-rule-engine
json python rule-engine rules rules-engine
Last synced: about 1 month ago
JSON representation
A rule engine where rules are defined in JSON format
- Host: GitHub
- URL: https://github.com/santalvarez/python-rule-engine
- Owner: santalvarez
- License: mit
- Created: 2022-12-19T17:58:15.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2025-06-07T19:38:35.000Z (10 months ago)
- Last Synced: 2025-08-17T16:54:03.060Z (8 months ago)
- Topics: json, python, rule-engine, rules, rules-engine
- Language: Python
- Homepage:
- Size: 71.3 KB
- Stars: 51
- Watchers: 1
- Forks: 6
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# python-rule-engine
[](https://pypi.python.org/pypi/python-rule-engine)
[](https://github.com/santalvarez/python-rule-engine)
[](https://github.com/pydantic/pydantic/blob/main/LICENSE)
[](https://pepy.tech/project/python-rule-engine)
[](https://pepy.tech/project/python-rule-engine)
A rule engine where rules are defined in JSON format. The syntax of the rules belongs to the [json-rules-engine](https://github.com/CacheControl/json-rules-engine) javascript library though it contains some changes to make it more powerfull.
- [Rule Syntax](docs/rules.md)
- [Operators](docs/operators.md)
## Installation
```
pip install python-rule-engine
```
## Quick Example
```python
from python_rule_engine import RuleEngine
rule = {
"name": "basic_rule",
"conditions": {
"all": [
{
# JSONPath support
"path": "$.person.name",
"operator": "equal",
"value": "Lionel"
},
{
"path": "$.person.last_name",
"operator": "equal",
"value": "Messi"
}
]
}
}
obj = {
"person": {
"name": "Lionel",
"last_name": "Messi"
}
}
engine = RuleEngine([rule])
results = engine.evaluate(obj)
```