How to rotate model so it matches X, Y and Z axises
While it is not a solution all on its own, How do I construct a transformation matrix from 3 vertices? shows how to create a matrix from 3 points.  You would have to get the coordinates of 3 points (and the first 2 you would pick to match one of the axes;  The third you would want to chose such that when combined with the other two defines one of the planes.)

Then you would need to take the inverse of that matrix and apply it to the matrix_world of your model.  Then it should align the model with the world axes.