This git repository contains simple examples of how to use the dnf python api
http://akozumpl.github.io/dnf/api.html
All examples is made in python 3, but should work in python 2.6+ also
python3 dnf-filter.py
python3 dnf-subject.py
sudo python3 dnf-install.py