What kind of doctor does an endoscopy and do you need a referral to see one?

Depends on. Where you are and what your insurance plan requires. Usually upper endoscopy looking at your esophagus, stomach and duodenum is done by a specialist, ie a gastroenterologist. Colonoscopy is done by a specialist, either GI or colon and rectal surgeon and some general surgeons in some areas of the country. If your ins plan requires a referral to a specialist, see your pcp to obtain one beforehand.