Yes, there is a solid way. It was discussed by The Building Coder 12 years ago:
https://thebuildingcoder.typepad.com/blog/2010/07/retrieve-structural-elements.html
You could probably have found it quite easily by searching the Internet. Please search before asking.
That said, the Revit API retrieval will be exactly equally solid as your definition of what exact elements you are interested in. That depends entirely on your use case. So, the implementation presented there may or may not exactly meet your needs. You will need to test and possibly (or almost certainly) modify it, adapting it to your exact requirements.