As Alan Storm mentioned, it is a very vast question but for magento you can do it several ways.
1) Create a magento module, and create controllers for each part of the API. For example, create controllers for catalog, customers, orders etc etc. Then call the appropriate objects and methods in those controllers.
2) The other way is not that good but i used it to fetch products from magento for an other website and is working perfectly. You will need to create a controller and handle all the API logic in that controller. Now, instead of creating controllers for each part, you will create helper classes for each part. During calling api, you have to pass class name and method name. In your API controller logic, you have to fetch that class and methods and check for its availability, load the class if available and call the method if in that helper class.
Hope this will help.