I am developing a video sharing site.
As you know if you go to YouTube, copy a link, paste it on the Facebook wall or a message, and then you can play it on Facebook without going to YouTube. As far as I know YouTube is the only site that does that. If you copy a link from Vimeo for example and paste it on Facebook, it will be displayed as thumbnail and you won’t be able to play it from Facebook.
So, is there an API that I can use to play videos from my site on Facebook when a user share a link, or is this feature only available for YouTube?
Yes, it is possible. You need to host a web page that has the proper Open Graph Protocol meta tags for each video format you offer on a given video.
Then someone needs to share that URL on Facebook. Facebook will crawl your website, parse the meta tags, and provide a video player.
Offering more video formats ensures better cross-browser compatibility.
Learn about the meta tags here: http://developers.facebook.com/docs/opengraph/
Use the Facebook debugger tool to make sure you are formatting your meta tags correctly: http://developers.facebook.com/tools/debug