No, there is no API for constructing entire data sources or data connections.
When you say that you wish to change dimensions, do you mean different fields within the same data connection? If so, you may be able to accomplish what you need by using Parameters and Calculated Fields to determine which dimensions are in play in a visualization. As a user changes the parameter choice, the calculated field can reference a different dimension based on the parameter value using CASE or IF/THEN statements.
I hope this helps,
Our business is aggregating survey data. When a question is added to a survey, we need to add a dimension for analysis on that question. We like to have a live connection for the data because as surveys are taken, those results are added to the dashboard instantly. As it stands, we have our backend team add the new question as a dimension to the datasource, then the front end team adds it to the appropriate dashboards and workbooks. What we would like to do is skip the part when we add the dimension manually and add it programatically instead.