Basically, it goes like this:
mysite.com/index.php/MODULE
then
MODULE -> Template
A module is what's called a "controller", which handles the logic, getting data from a model (the api), and passing that data to a view (template) to output.
Usually, most new programmers will plop everything into one file - all their SQL, their PHP and the HTML, all into one big file, which makes it a mess to extend, and a big mess to debug and eventually the next person who has to look at it, will shoot themselves (I come across alot of this code, it's not pretty).
But this method is called "MVC" programming, "Model-view-controller", where the controller (a module) is the brain for that peice, and it will talk to the model (api) and then send its final data to the view (a template). This way is very powerful as you can shift things around, etc.
In my methodology, I do the main Template::Set() calls in the Controller after getting the data from the model, and then Template::Show(), then in the template, I show the final output. That way, there are no calls to the model within a template, and it's very clear where to look for specific things; if you want to know how variables are set for the template, you check the controller. If you want to see what template is called, you check the controller. If you want to see what data is used, you check the controller, then you check the model since you'll know the exact path it's taking. And you can wrestle around with the template without touching anything in the controller or model. This way it's also really easy to see where bugs really are.
Maybe reading this will help:
http://en.wikipedia.org/wiki/Model-view-controller
http://www.codinghorror.com/blog/archives/001112.html