any free WHOIS PHP/Perl systems that can be customized to fit with my site?

and which domain registrars offer an API to sell domains?