I am using js-libp2p. How to generate peer info on runtime?

I am using js-libp2p. How to generate peer info on runtime?
I just knew a way just using ipfs command line to get one,but I just want to generate one when I run my program is there a api about this?