How to make qr codes for wifi

I want to make a app in which users can enter wifi details like username, wifi password and then generates a qr code

and if anyone scans the qr code wifi automatically gets connected

how to use api for that any tutorial ?

search the community to find tutorials about how to use an API