Maybe using the electrostatic analogue you can get approximately valid results. As we know we can consider a magnet as a magnetic dipole and then do the maths for interaction of two dipoles as we would have done in the electrostatic realm.
The magnetic field due to a magnet at axis is taken to be as
$B_a= (2\mu m)/(4\pi r^3)$
And equatorially as
$B_e = (\mu m)/(4\pi r^3)$.
Here $m$ is magnetic moment of magnet, $\mu$ is permeability of medium and $r$ is distance from centre of magnet. There is also the assumption that the magnet is small as compared to distance on which force is considered.
Now you can simple consider one magnets field at some distance and do simple calculations for magnet-field interaction for the other magnet.
Added as response to comment :
You can find fields at distance r-a and r+a from an electric dipole by either using this simplified formula or that long one from which this one is approximated. Then you can multiply them by charges that you have placed by placing the dipole, this will give you force on individual charges on added then you will get force on the dipole. This you can then use for analogue with magnetic dipole, replacing p by m (electric dipole moment by magnetic dipole) and the constant of electric force with that of magnetic one.
Note : i have omitted the mathematical proof here because of the various permutations in which the dipoles could be with respect to one another, still if some help is needed regarding a particular case i would be more than happy to help.