GitHub REST API

11950 단어
우리 대부분은 매일은 아니지만 GitHub 서비스를 자주 사용합니다.

학생이라면 GitHub에서 훌륭한 도구와 무료로 사용할 수 있는 학생용 패키지를 제공합니다. 에서 내 기사를 확인하십시오.

이 기사에서는 GitHub REST API를 사용하여 포트폴리오 웹 사이트에 저장소를 표시하는 방법을 안내합니다. postman을 사용하여 API를 테스트하겠습니다.

GitHub REST API Documentation .

API로 놀기



API가 개인적인 용도로 무엇을 제공할 수 있는지 보여드리기 위해 사용하겠습니다. 이를 위해 엔드포인트를 사용하여 사용자의 저장소를 가져옵니다.

https://api.github.com/users/{github_username}
https://api.github.com/users/{github_username}/repos







GitHub 사용자 엔드포인트 사용:




https://api.github.com/users/{github_username}



즉:

https://api.github.com/users/achingachris



그러면 GitHub 사용자 세부 정보가 반환됩니다.

{
    "login": "",
    "id": ,
    "node_id": "",
    "avatar_url": "",
    "gravatar_id": "",
    "url": "",
    "html_url": "https://github.com/achingachris",
    "followers_url": "https://api.github.com/users/achingachris/followers",
    "following_url": "https://api.github.com/users/achingachris/following{/other_user}",
    "gists_url": "https://api.github.com/users/achingachris/gists{/gist_id}",
    "starred_url": "https://api.github.com/users/achingachris/starred{/owner}{/repo}",
    "subscriptions_url": "https://api.github.com/users/achingachris/subscriptions",
    "organizations_url": "https://api.github.com/users/achingachris/orgs",
    "repos_url": "https://api.github.com/users/achingachris/repos",
    "events_url": "https://api.github.com/users/achingachris/events{/privacy}",
    "received_events_url": "https://api.github.com/users/achingachris/received_events",
    "type": "User",
    "site_admin": false,
    "name": "chrisdevcode",
    "company": null,
    "blog": "",
    "location": "Kenya",
    "email": null,
    "hireable": null,
    "bio": "React | Next | Node | C#(dotnet)\r\n\r\nTech Community Lover",
    "twitter_username": null,
    "public_repos": 211,
    "public_gists": 15,
    "followers": 91,
    "following": 117,
    "created_at": "2019-04-29T22:17:15Z",
    "updated_at": "2021-07-15T06:56:22Z"
}



이것을 사용하여 다음을 표시할 수 있습니다.
  • 공개 저장소 및 요지
  • GitHub 계정을 만든 날짜
  • GitHub 바이오
  • 내가 팔로우하는 사람과 팔로우하는 사람의 수.

  • GitHub 사용자 저장소 엔드포인트 사용:




    https://api.github.com/users/{github_username}/repos
    
    


    즉:

    https://api.github.com/users/achingachris/repos
    
    


    반환된 결과:

    PS - 또한 사용자 세부 정보와 모든 저장소를 반환합니다.

    {
            "id": 300814209,
            "node_id": "MDEwOlJlcG9zaXRvcnkzMDA4MTQyMDk=",
            "name": "AI-ML-Bootcamp",
            "full_name": "achingachris/AI-ML-Bootcamp",
            "private": false,
            "owner": {
                "login": "achingachris",
                "id": 50122165,
                "node_id": "MDQ6VXNlcjUwMTIyMTY1",
                "avatar_url": "https://avatars.githubusercontent.com/u/50122165?v=4",
                "gravatar_id": "",
                "url": "https://api.github.com/users/achingachris",
                "html_url": "https://github.com/achingachris",
                "followers_url": "https://api.github.com/users/achingachris/followers",
                "following_url": "https://api.github.com/users/achingachris/following{/other_user}",
                "gists_url": "https://api.github.com/users/achingachris/gists{/gist_id}",
                "starred_url": "https://api.github.com/users/achingachris/starred{/owner}{/repo}",
                "subscriptions_url": "https://api.github.com/users/achingachris/subscriptions",
                "organizations_url": "https://api.github.com/users/achingachris/orgs",
                "repos_url": "https://api.github.com/users/achingachris/repos",
                "events_url": "https://api.github.com/users/achingachris/events{/privacy}",
                "received_events_url": "https://api.github.com/users/achingachris/received_events",
                "type": "User",
                "site_admin": false
            },
            "html_url": "https://github.com/achingachris/AI-ML-Bootcamp",
            "description": "Artificial Intelligence and Machine Learning Bootcamp - Strathmore University",
            "fork": false,
            "url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp",
            "forks_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/forks",
            "keys_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/keys{/key_id}",
            "collaborators_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/collaborators{/collaborator}",
            "teams_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/teams",
            "hooks_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/hooks",
            "issue_events_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/issues/events{/number}",
            "events_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/events",
            "assignees_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/assignees{/user}",
            "branches_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/branches{/branch}",
            "tags_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/tags",
            "blobs_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/git/blobs{/sha}",
            "git_tags_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/git/tags{/sha}",
            "git_refs_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/git/refs{/sha}",
            "trees_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/git/trees{/sha}",
            "statuses_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/statuses/{sha}",
            "languages_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/languages",
            "stargazers_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/stargazers",
            "contributors_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/contributors",
            "subscribers_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/subscribers",
            "subscription_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/subscription",
            "commits_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/commits{/sha}",
            "git_commits_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/git/commits{/sha}",
            "comments_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/comments{/number}",
            "issue_comment_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/issues/comments{/number}",
            "contents_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/contents/{+path}",
            "compare_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/compare/{base}...{head}",
            "merges_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/merges",
            "archive_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/{archive_format}{/ref}",
            "downloads_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/downloads",
            "issues_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/issues{/number}",
            "pulls_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/pulls{/number}",
            "milestones_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/milestones{/number}",
            "notifications_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/notifications{?since,all,participating}",
            "labels_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/labels{/name}",
            "releases_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/releases{/id}",
            "deployments_url": "https://api.github.com/repos/achingachris/AI-ML-Bootcamp/deployments",
            "created_at": "2020-10-03T06:39:03Z",
            "updated_at": "2020-10-07T19:30:57Z",
            "pushed_at": "2020-10-07T19:30:54Z",
            "git_url": "git://github.com/achingachris/AI-ML-Bootcamp.git",
            "ssh_url": "[email protected]:achingachris/AI-ML-Bootcamp.git",
            "clone_url": "https://github.com/achingachris/AI-ML-Bootcamp.git",
            "svn_url": "https://github.com/achingachris/AI-ML-Bootcamp",
            "homepage": "",
            "size": 140,
            "stargazers_count": 1,
            "watchers_count": 1,
            "language": "Jupyter Notebook",
            "has_issues": true,
            "has_projects": true,
            "has_downloads": true,
            "has_wiki": true,
            "has_pages": false,
            "forks_count": 0,
            "mirror_url": null,
            "archived": false,
            "disabled": false,
            "open_issues_count": 0,
            "license": {
                "key": "mit",
                "name": "MIT License",
                "spdx_id": "MIT",
                "url": "https://api.github.com/licenses/mit",
                "node_id": "MDc6TGljZW5zZTEz"
            },
            "forks": 0,
            "open_issues": 0,
            "watchers": 1,
            "default_branch": "main"
        },
    
    


    여기에서 이를 사용하여 훨씬 쉽게 GitHub 저장소의 세부 정보를 표시할 수 있습니다.

    사용자를 위한 GitHub REST API 사용에 대해 자세히 알아보려면 다음을 방문하세요.

    https://docs.github.com/en/rest/reference/users

    다음 단계



    NEXTJS 앱에서 GitHub API를 사용하는 방법에 대한 자습서는 내 블로그를 확인하십시오.

    좋은 웹페이지 즐겨찾기