Export segmentation to file API

is there a way to use the export segmentation functionality without opening Slicer,
I have a folder of many segmented .nii file and I am looking for a script that can convert it to .obj file.

Yes, sure that should be no problem at all. You can put your code snippet into a .py file and run it Slicer’s Python environment.