Export subset as FBX

I'm trying to mimic the UI's export selection as an FBX but via script, but I can only seem to be able to export the whole active scene.

Can anyone point me to the docs or a sample script to achieve that?