Pithub::Result(3pm)
π Pithub::Result β the manual page, but make it a group chat π
okay bestie, so this is Pithub::Result(3pm), from the User Contributed Perl Documentation crew. Version? version 0.01043. She's a Github v3 result object and she is, frankly, the main character of every single API call you're about to make. π
β¨ NAME β¨
Pithub::Result β a Github v3 result object. that's her. that's the whole vibe. π
πΈ VERSION πΈ
version 0.01043. write it down, she said what she said. β
π¦ DESCRIPTION π¦
so here's the tea: every method call that maps directly to a Github API call hands you back a Pithub::Result object. every single one. no exceptions, no cap. π«Ά
and once you've got that result object in your hands? you can set attributes on it, or you can call methods on it. that's it. that's the whole relationship. you're in charge now. π
π ATTRIBUTES π
π auto_pagination
set this bad boy to true and then use the next method to iterate over the result rows β it'll call next_page for you, automatically, until you've got all the results. so convenient. so slay. β¨
β οΈ but bestie, be careful with this feature. if there are 100 pages, this will make 100 API calls. that's a lot of calls. that's a lot of rate limit. protect yourself. π
by default it's off. and psst β instead of setting it per Pithub::Result, you can also set it directly on any of the Pithub API objects. flexible queen. π
Examples:
my $r = Pithub::Repos->new;
my $result = $r->list( user => 'rjbs' );
# This would just show the first 30 by default
while ( my $row = $result->next ) {
printf "%s: %s\n", $row->{name}, $row->{description};
}
# Let's do the same thing using auto_pagination to fetch all
$result = $r->list( user => 'rjbs' );
$result->auto_pagination(1);
while ( my $row = $result->next ) {
printf "%s: %s\n", $row->{name}, $row->{description};
}
# Turn auto_pagination on for all L<Pithub::Result> objects
my $p = Pithub::Repos->new( auto_pagination => 1 );
my $result = $p->list( user => 'rjbs' );
while ( my $row = $result->next ) {
printf "%s: %s\n", $row->{name}, $row->{description};
}
π content
the decoded JSON response, babes. π§ it might be an arrayref or a hashref, depending on which API call you made β she's versatile like that. and for some calls? there's literally no content at all. empty. nothing. the void. π
π first_page_uri
the extracted value from the Link header, for the first page. this can return undef. π«
π last_page_uri
the extracted value from the Link header, for the last page. this can return undef. π«
π next_page_uri
the extracted value from the Link header, for the next page. this can return undef. π«
π prev_page_uri
the extracted value from the Link header, for the previous page. this can return undef. π«
π response
the HTTP::Response object. that's it, that's the attribute. iconic. β¨
π utf8
this one can set the utf8 flag. do with that what you will, bestie. π
π₯ METHODS π₯
π raw_content
returns the content of the API response as a string. and yeah, it'll probably be JSON. no promises, but like, probably. π
π request
returns the HTTP::Request object that was used to make the API call. the receipts, basically. π§Ύ
π code
returns the HTTP code from the API call. 200? 404? she'll tell you. π
π success
returns whether the API call was successful. vibe check passed or not, fr fr. β
π count
returns the count of the elements in content. and here's the lil quirk: if the result isn't an arrayref but a hashref, it will still return 1. but some calls return an empty hashref β for those calls, it returns 0. so there's nuance, okay? respect the nuance. π
π first
returns the first element from content if content is an arrayref. if it's a hashref? it just returns that hashref. she's not gonna make it weird. π«Ά
π first_page
get the Pithub::Result of the first page. returns undef if there's no first page β so like, if you're already on the first page, or if there are no pages at all. π«
π get_page
get the Pithub::Result for a specific page. heads up: the parameter is not validated β if you hit a page that doesn't exist, the Github API itself will tell you so. π
and if there's only one page? this method returns undef, no matter which page you ask for. even for page 1. yes, even that one. sorry bestie. π
π last_page
get the Pithub::Result of the last page. returns undef if there's no last page β if you're already on the last page, or if there's only one page, or no pages at all. the undef is coming from inside the house. π«
π next
so most of the results the Github API hands back are arrayrefs of hashrefs. you can grab those data structures directly by calling content. but besides that, you can also just iterate over the results using this method. choose your fighter. π
Examples:
my $r = Pithub::Repos->new;
my $result = $r->list( user => 'rjbs' );
while ( my $row = $result->next ) {
printf "%s: %s\n", $row->{name}, $row->{description};
}
π next_page
get the Pithub::Result of the next page. returns undef if there's no next page β which happens when there's only one page at all. π₯²
Examples:
- list all followers in order, from the first one on the first page all the way to the last one on the last page. see also
auto_pagination. πΈ
my $followers = Pithub->new->users->followers;
my $result = $followers->list( user => 'rjbs' );
do {
if ( $result->success ) {
while ( my $row = $result->next ) {
printf "%s\n", $row->{login};
}
}
} while $result = $result->next_page;
the nature of the implementation requires you to do a do { ... } while ... loop here. and ngl, if you're planning to fetch all the results of all the pages, I suggest you use the auto_pagination feature instead β it's much more convenient. trust. π«Ά
π prev_page
get the Pithub::Result of the previous page. returns undef if there's no previous page β which means you're on the first page already. π₯²
Examples:
- list all followers in reverse order, from the last one on the last page all the way back to the first one on the first page. see also
auto_pagination. πΈ
my $followers = Pithub->new->users->followers;
my $result = $followers->list( user => 'rjbs' )->last_page; # this makes two requests!
do {
if ( $result->success ) {
while ( my $row = $result->next ) {
printf "%s\n", $row->{login};
}
}
} while $result = $result->prev_page;
π not me pointing out that ->last_page there makes two requests! the comment in the code says it, I'm just saying it louder. π
π etag
returns the value of the ETag http header. β¨
π ratelimit
returns the value of the X-Ratelimit-Limit http header. know your limits, bestie. π
π ratelimit_remaining
returns the value of the X-Ratelimit-Remaining http header. π
π AUTHOR π
Johannes Plunien <plu@cpan.org> β give her her flowers. π·
π COPYRIGHT AND LICENSE π
This software is copyright (c) 2011 by Johannes Plunien.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. periodt. π
and that's the whole page, bestie!! π written up as part of the User Contributed Perl Documentation, running on perl v5.40.1, dated 2025-06-08, and honestly? she ate. go forth and paginate responsibly. π¦β¨π
π¦ where this page comes from
- debian trixie: libpithub-perl 0.01043-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libpithub-perl 0.01043-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libpithub-perl 0.01043-1 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms