Ed Law and his team has put together awesome resources for calculating OPR that can be found
here.
Calculating OPR isn't actually that hard, although it requires some knowledge about basic linear algebra. Essentially, you are trying to solve a linear system of equations for a certain constant that is what you expect a team to contribute to an alliance each match (OPR). If you have teams a, b, and c playing together in one match, and they score a x amount of points, you are solving
a(OPR) + b(OPR) + c(OPR) = x
As more matches occur, the matrix equations become more complex. In the form of Ax = b, A is the matrix whose values correspond to the amount of matches teams played with each other, x is the OPR vector, and b is the vector of the total score each team made in all the matches they played.
If you don't want to do the hard math/plug in your own match scores, you can use
The Blue Alliance's API to get OPRs off their site.