The developer’s reference is a great place to start. You’ll find get_permalink
in wp-includes/link-template.php
.
You might want to look into wp-cli wp post list --post__in=1 --field=url
should do the trick as discussed in wp-cli issue#2727
Also, there’s the rest-api to consider. The best solution for getting the permalink might be to just post/cURL a request to WordPress’ rest-api to get the permalinks you want.
This question might be a good place to start: WP JSON list all permalinks
For example, you could do something like the following:
curl https://example.com/wp-json/wp/v2/posts/<id>
or curl https://example.com/wp-json/wp/v2/pages/<id>
& then find the guid
/ permalink from there.