GitHub API Fundamentals Quiz: Core Concepts and Usage Quiz

Explore essential principles of the GitHub API, including authentication, endpoints, rate limits, and data formats. This quiz assesses your understanding of key operations and usage best practices within the broader tools ecosystem relevant to repositories and development workflows.

  1. Authentication Methods

    Which of the following is a valid way to authenticate when making requests to the GitHub API for accessing private repository data?

    1. Personal access token
    2. OAuth2 device flow
    3. Session ID from browser cookies
    4. CAPTCHA response

    Explanation: A personal access token is an acceptable method for authenticating with the GitHub API to access private data. OAuth2 device flow is not directly supported as an authentication method for this API; instead, OAuth2 web or app flows may be used. Session IDs from browser cookies are relevant in web authentication but not in API requests. CAPTCHA responses are completely unrelated to API authentication and are used for distinguishing bots from humans on forms.

  2. API Endpoint Usage

    If you want to retrieve information about a specific user's public profile via the API, which general endpoint should you use?

    1. /users/{username}
    2. /repos/{username}
    3. /gists/{username}
    4. /commits/{username}

    Explanation: /users/{username} is the correct endpoint for fetching public profile information for a specific user. /repos/{username} would try to fetch information about a repository and would require the repository name. /gists/{username} is for accessing a user's gists, not profile information. /commits/{username} does not exist as a valid endpoint and would not return user profile data.

  3. Rate Limiting

    What typically happens if you exceed your allowed rate limit when accessing the GitHub API?

    1. The API responds with HTTP status code 403 Forbidden
    2. The API deletes your account
    3. The API responds with HTTP status code 429 Too Many Requests
    4. The API returns incorrect data

    Explanation: When you exceed the rate limit, the API returns a 403 Forbidden status with information about when you can retry. Status code 429 Too Many Requests is sometimes used in other APIs but is not currently implemented in this one. The API does not delete your account or return random incorrect data for rate limit violations—only access is temporarily restricted.

  4. Data Formats

    Which data format is primarily used for responses returned by the GitHub API by default?

    1. JSON
    2. XML
    3. YAML
    4. CSV

    Explanation: JSON is the default and primary data format for responses from the GitHub API, making it easy to parse in most programming languages. XML and YAML are not offered as standard response formats. CSV is also not supported by default and is less suitable for representing structured API data.

  5. Creating a New Issue

    When creating a new issue in a repository using the API, which HTTP method should you use?

    1. POST
    2. GET
    3. PUT
    4. DELETE

    Explanation: The POST method is used to create new resources such as issues via the API. GET is used for retrieving data and would not create new issues. PUT is typically used for updating an existing resource or creating a resource at a specific location, while DELETE is for removing resources. The other methods are unsuitable for submitting new issues.