Well, you have several solution depending how complex you want it to be.
1. If you want something simple, easy and that is already provided via RBTools, use it (or it's API). Just call it from your own Python script, simple, easy, just build the command line/API call and execute it.
2. If you want more control and more access/features (ie creating repository), you will want to use the webAPI. When understood it's not hard to use and open a whole lot possibilities.
The doc for the webAPI will tell you the parameters, up to you to create the call and parse result (JSON).