Create rigid body constraints without using ops?

I’m currently working on an addon where I need to create a lot of rigid body constraints. Using the Operator for this is very slow. I currently create a template for this and makes copies of that since this is way faster.

This feels a bit hackyish so I have searched for a way to do this in a proper way. Is there a way to create the rigid_body_constraint structure without using an operator?