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.
Which of the following is a valid way to authenticate when making requests to the GitHub API for accessing private repository data?
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.
If you want to retrieve information about a specific user's public profile via the API, which general endpoint should you use?
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.
What typically happens if you exceed your allowed rate limit when accessing the GitHub API?
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.
Which data format is primarily used for responses returned by the GitHub API by default?
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.
When creating a new issue in a repository using the API, which HTTP method should you use?
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.