GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Pagination for the get_contents function? · Issue #1626 · PyGithub/PyGithub

Pagination for the get_contents function? #1626

New issue
Copy link
New issue
Copy link
Closed
Closed
Pagination for the get_contents function?#1626
Copy link

Description

@ThomasHineXYZ
ThomasHineXYZ
opened on Jul 28, 2020
Issue body actions

Hi, I'm trying to list the contents of a directory in a Github project, the only issue I'm running in to is that it is maxing out at 1000 entries. I know that the Github API has pagination support, but I tried adding page=2 to the get_contents() function, but it just errors out.

How would I go about adding pagination or loading the next set of values from the get_contents function?

        repo = self.github.get_repo("<repo>")
        contents = repo.get_contents("<folder>")
        for file in contents:
            print(file.path)

Activity

  1. s-t-e-v-e-n-k commented on Jul 28, 2020

    @s-t-e-v-e-n-k
    s-t-e-v-e-n-k
    on Jul 28, 2020
    Collaborator
    More actions

    From the GitHub API documentation: "This API has an upper limit of 1,000 files for a directory. If you need to retrieve more files, use the Git Trees API." That API is using the Repository.get_git_tree() endpoint.

  2. s-t-e-v-e-n-k
    closed this as completedon Jul 28, 2020
  3. ThomasHineXYZ commented on Jul 28, 2020

    @ThomasHineXYZ
    ThomasHineXYZ
    on Jul 28, 2020
    Author
    More actions

    Hmm, interesting.

    I guess I haven't used the API since v2 and they changed that. Thank you.

  4. ThomasHineXYZ
    changed the title [-]Paginatoin for the get_contents function?[/-] [+]Pagination for the get_contents function?[/+] on Jul 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      You are visitor 01402775 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.