I was laughing at Bernd's casual suggestion for writing a field detection plug-in. This is not a trivial task. It's the kind of thing you build an AI for.
However, what you are asking for is a PDF library or Tool for building an external application. There are many PDF libraries and single function development tools. I am not aware of any that do auto-form field detection, although it wouldn't surprise me if there were some out there. For example I just did a google search on "Auto Detect PDF Form Fields". The first page is all articles/forum threads about using Acrobat to autodetect fields, but at the bottom was this online tool for doing it.
Form Field Detector - Accusoft
It looks like an online service you can connect to from your own HTML page using JS.
Also, I haven't checked but I maybe this capability is avaliable from the official PDF Library, distributed by DataLogics:
https://www.datalogics.com/products/pdf/pdflibrary/
And it is in C++. You'll find many of the PDF tools and libraries are Java and .Net