Pithub...ontents(3pm)
β¨ NAME β¨
Pithub::Repos::Contents β the Github v3 Repo Contents API π like... it's the part of Pithub that goes and peeks inside repos, bestie. Files, dirs, READMEs, tarballs. The whole snack table π
πΈ VERSION πΈ
version 0.01043 β yes queen, that's the one we're on β¨
π METHODS π
π archive
okay so this one is iconic: it hands you back a 302 pointing at a URL where you can download a tarball or zipball archive of a repo. Like it doesn't hand you the snack, it hands you the address of the snack. iykyk π
β οΈ note bestie, for real: for private repositories, these links are temporary and expire quickly π do not be out here saving them for later, they will be GONE. lowkey tragic.
GET /repos/:user/:repo/:archive_format/:ref
the ref parameter is optional and defaults to master π
Examples:
use Path::Tiny;
my $c = Pithub::Repos::Contents->new(
repo => 'Pithub',
user => 'plu'
);
my $result = $c->archive( archive_format => 'tarball' );
if ( $result->success ) {
path('Pithub-master.tgz')->spew($result->raw_content);
}
$result = $c->archive( archive_format => 'tarball', ref => 'other_branch' );
if ( $result->success ) {
path('Pithub-other_branch.tgz')->spew($result->raw_content);
}
π¦ get
this is the main character fr fr π it returns the contents of any file or directory in a repository. any. file. or. directory. obsessed.
GET /repos/:user/:repo/contents/:path
Optional Parameters:
refβ optional string, the String name of the Commit/Branch/Tag. defaults tomasterβ¨
Examples:
my $c = Pithub::Repos::Contents->new(
repo => 'Pithub',
user => 'plu'
);
# List all files/directories in the repo root
my $result = $c->get;
if ( $result->success ) {
say $_->{name} for @{ $result->content };
}
# Get the Pithub.pm file
$result = $c->get( path => 'lib/Pithub.pm' );
print Dumper $result->content if $result->success;
like, the first one is just "what's in here bestie" and the second one is "gimme that specific file" π«Ά both slay.
π§ readme
this one goes and grabs the preferred README for a repository π it knows which one is the vibe, you don't have to pick. that's the whole point of "preferred". trust.
GET /repos/:user/:repo/readme
Optional Parameters:
refβ optional string, the String name of the Commit/Branch/Tag. defaults tomasterπ
Examples:
my $c = Pithub::Repos::Contents->new(
repo => 'dotfiles',
user => 'plu'
);
my $result = $c->readme;
if ( $result->success ) {
print Dumper $result->content;
}
# Get the readme of branch 'other_branch'
$result = $c->readme( params => { ref => 'other_branch' } );
print Dumper $result->content if $result->success;
see how the second one passes ref inside params? that's the little plot twist, bestie, don't miss it π
π AUTHOR π
Johannes Plunien <plu@cpan.org> β legend behavior, no cap π
β 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. π«Ά like, go off, remix it, it's yours.
and that's the whole page, bestie!! π this lil cutie came from the User Contributed Perl Documentation, running on perl v5.40.1, dated 2025-06-08. mwah, periodt π
β¨π
π¦ 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