I think I've figured out a native way to do this using only sysfs, though I can't guarantee it 100% given the nature of Linux...
(NOTE: this is for testing a particular device rather than a slot)
I'll be focusing on the PCI(e) device hierarchy, but such devices can also be accessed via /sys/bus/pci/drivers/* among other locations you intend to verify from.
From what I've discovered so far, all of my PCIe devices seem to have the link directory:
/sys/devices/pci0000:00/<devicepath>/link/
Where as all of my PCI devices so far have no trace of that directory.
Simply running a test <devicepath>/link/ seems to be enough to tell you if a device is PCIe or PCI.
$ test -d "/sys/devices/pci0000:00/0000:00:00.2/link" && echo true
true
if test -d "/sys/devices/pci0000:00/0000:00:00.2/link"; then
# device is PCIe
else
# device is PCI
fi