Is the expression "By the gods!" an interjection?

In the work of art it reads as follows: "No, by the gods! Would that it had been!"


The phase is mainly used when someone is shocked or surprised by something they hear, read or see which causes them to spontaneously react by saying "By the gods!". So yes, it's most common usage is as an interjection.