Skip to content

Searching for Code, Web and API differ #2956

Closed
@FHantke

Description

@FHantke

Searching for Code, Web and API differ

Hi all,

I am not sure if this is the correct repository to open this issue, but I did not find any other better fitting one.
I started playing around with the Git rest API today to search for code snippets. However, after a few searches, I realized that the API finds less files than the normal web search. Is there an option that prevents the search from showing all results?

My code is simply a request to the /search/code endpoint.

    headers = {
        'Accept': 'application/vnd.github+json',
        'Authorization': f'Bearer {GIT_API_KEY}',
        'X-GitHub-Api-Version': '2022-11-28',
    }

    params = { 'q': '"Hello World"' }

    res = requests.get('https://api.github.com/search/code', params=params, headers=headers)
    json_data = res.json()
    print(f"Total count: {json_data['total_count']}")

The API returns 817152 results, while using the GitHub web search return 4.6M.

image

I would expect to find the same number of files with both methods.

Thank you
Florian

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions