Update API.php

Use API singleton instead of manual implementation.