Full API implementation and tests.

Includes cache and key management with tests.