I've used MarineTraffic.com for finding details about yachts and ships I've seen in ports. It's a really cool website.
They also have an API, but, unfortunately, there is no free access.
There is an API option from FleetMon that is mostly-free:
The FleetMon Public API lets software developers create great software apps that are able to display ship positions and master data, port calls, weather conditions, ports and much more. Developers get a powerful tool to connect their software to the FleetMon.com Vessel Database, enabling them to develop own services as well as integrate with existing IT systems and logistics solutions.
This would be a better option, although I don't know how complete their DB is.