Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How Can I get My Social Preview Image Link of My Github Repo using Git API or Any Logic?

I own many github repository and I usually add projects on weekly basis. I am making my own website using github pages, since I can only host static website on Github Pages hence I am Going to Use Github API in Order to Automatically Update My New Projects On My Website. But I also Want to Add a Preview/Sample Image to It.

I Got to Know that there is an Option Named Social Preview Where I can Add an Image of My Repository to be Shown on Social Media.

Although I can Get My all Repo Info From api.github.com but I can't get my Social Media Preview Image Url.

like image 614
imLolman Avatar asked Jun 20 '19 17:06

imLolman


1 Answers

GitHub GraphQL API v4 has a field to query the OpenGraph image URL. It uses the social image set in the repo settings and fallbacks to the user profile image.

Link to docs and search for "openGraphImageUrl".

You can test this out with GitHub's GraphQL API explorer (sign in required) and query:

{
  repository(owner: "vuetifyjs", name: "vuetify") {
    openGraphImageUrl
  }
}
like image 183
Bjorn Lu Avatar answered Sep 22 '22 15:09

Bjorn Lu