Search code examples
github-apioctokit

Getting repository contents using GitHub API


I know there is an API for getting repository content. But my use case is I need to get the whole repository and display it in my UI like GitHub UI. Similar to GitHub UI, I need my repository to be displayed in my UI. Is there any API I can use to get the whole repository so I can display that in my UI.

I tried this API.

curl \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: Bearer <YOUR-TOKEN>" \
  https://api.github.com/repos/OWNER/REPO/zipball/REF

But it gives separate file contents. I need the whole repo.


Solution

  • Getting the all repository remains easier with a simple git clone. No need for an API call there.

    If, as mentioned in this 2016 octokit issue, you cannot clone through GitHub API, you could use libgit2sharp to integrate the clone operation in your application.