Pyembroidery
Pyembroidery is a python library for the reading and writing of embroidery files.
Follow the link above. The README file has a lot of information how it can be used and how it is working.
Background
Ink/Stitch started out using libembroidery, developed by the Embroidermodder team.
@tartarize then provided a conversion to python (pyembroidery) to make it even more useful for Ink/Stitch (or any other python based embroidery project).
The pyembroidery version used by the Ink/Stitch organization is a fork of his work.
Embroidery File Formats
The EduTech wiki is a good resource for embroidery concepts.
You can also find very detailed information about embroidery file formats.