TestApi is a general purpose API library that can be used within a variety of different contexts – from within a VS test to a standalone app. TestApi enables development of tools and/or automated tests, both in a whitebox and black box fashion. It is not specifically targeted to any type of testing.

Coded UI is a facility in VS that allows you to automate your UI tests, using the UIA API under the covers. It's specifically targeted to UI tests.