The id read-only property of the MIDIPort interface returns the unique ID of the port.
id
MDN Reference