Risks can be associated with all Portfolio Item types and User Stories. In this scenario, the Epics are directly above Feature, so I will use this for the following examples.
It would be possible to use the API to search for all risks associated with a specific Epic with the following API call. In the following URL, I searched for a specific initiative (I9). It will be necessary to change the Workspace ObjectID to your specific Workspace ObjectID - and of course change the Initiave ID to your own as well:
https://rally1.rallydev.com/slm/webservice/v2.0/portfolioitem/initiatave?workspace=https://us1.rallydev.com/slm/webservice/v2.0/workspace/18888882765&query=(FormattedID = "I9")&fetch=true&start=1&pagesize=20
However, the above does not search for all risks associated with the Features or User Stories associated with that Iteration. This would have to be done in separate API calls - one for Feature and one for User Stories.
To make the queries run faster for Features and User Stories, it would be possible to use (Risks.ObjectID != null) in the query to only pull the User Stories or Features that have Risks associated with them.