Check out
https://aumayr.github.io/beancount-docs-static/api_reference/beancount.prices.html
You need to use the "-e" command line parameter to pass in the string, including the source. For example if you want to get the price for Amazon stock from Yahoo: bean-price -e "USD:yahoo/AMZN"
You can also define this string as part of your commodity. Then you can just run bean-price on your main file and it will automatically pull the prices for all commodities that you currently hold. Again, with the Amazon example, the commodity could be defined like this:
1997-05-15 commodity AMZN
name: "Common shares of Amazon"
price: "USD:yahoo/AMZN"
Yahoo already comes built-in as a source. I think some others do too, but I can't remember which ones (I think Google, maybe some others - check the source code or docs). If you need additional sources, you can write your own too. Here's a hacky example I wrote (and use myself) to get prices for cryptocurrencies from
coinmarketcap.com:
https://github.com/aamerabbas/beancount-coinmarketcap