Pithub(3pm)

πŸ“¦
version 0.01043 Β· 4 versions
, in debian trixie, ubuntu resolute, ubuntu stonking

πŸ’– NAME πŸ’–

Okay bestie, welcome to Pithub β€” the Github v3 API in Perl form. This page is from the User Contributed Perl Documentation collection, and yes, it's called Pithub(3pm). Periodt. πŸ’…


✨ VERSION ✨

version 0.01043 ✨


🫢 SYNOPSIS 🫢

Real talk, this is the vibe in code form:

use Pithub ();

my $p = Pithub->new;
# my $p = Pithub->new(utf8 => 0); # enable compatibility options for version 0.01029 or lower
my $repo = $p->repos->get( user => 'plu', repo => 'Pithub' );

# $repo->content is either an arrayref or an hashref
# depending on the API call that has been made
printf "%s\n", $repo->content->{html_url};     # prints https://github.com/plu/Pithub
printf "%s\n", $repo->content->{clone_url};    # prints https://github.com/plu/Pithub.git

# if the result is an arrayref, you can use the result iterator
my $repos = $p->repos->list( user => 'plu' );
while ( my $row = $repos->next ) {
    printf "%s\n", $row->{name};
}

# Connect to your local GitHub Enterprise instance
my $ghe_p = Pithub->new(
    api_uri => 'https://github.yourdomain.com/api/v3/'
);

# No need to provide user/repo to each module:
my $pit = Pithub->new(
  user  => 'plu',
  repo  => 'pithub',
  token => 'my_oauth_token',
);

$pit->repos->get;
$pit->repos->commits->list;

# Use a caching UserAgent
use CHI                    ();
use Pithub::Repos          ();
use WWW::Mechanize::Cached ();

my $cache = CHI->new(
    driver   => 'File',
    root_dir => '/tmp/pithub-example'
);

my $mech = WWW::Mechanize::Cached->new( cache => $cache );

my $cached_pithub = Pithub::Repos->new(
    auto_pagination => 1,
    per_page        => 100,
    ua              => $mech,
);

Obsessed with how clean that is, honestly. πŸ¦‹


🌸 DESCRIPTION 🌸

So Pithub (that's Perl + Github, iconic name behavior) hands you a whole set of modules to talk to the Github v3 API at http://developer.github.com/v3/ β€” and it does it all in an object oriented way, which is exactly the energy we're bringing today.

There's also Net::GitHub, which does the same thing but for all the versions (v1, v2, v3) of the Github API. Pithub? It supports all API calls so far, but only for v3. Pick your fighter. πŸ’€


πŸ‘‘ ATTRIBUTES πŸ‘‘

πŸŽ€ search_api πŸŽ€

my $p = Pithub->new({ search_api => 'v3' });
my $search = $p->search; # $search->isa('Pithub::SearchV3');

This attribute is literally just you telling it which API to use for searches by default. The two accepted values are "v3" and "legacy". And because compatibility reasons, the default is "legacy". Not me still defaulting to legacy in this economy 😭 β€” but okay, it is what it is.


πŸ’… METHODS πŸ’…

Every one of these is your lil gateway module, and they all just provide access to their thing. Go off, king. πŸ”₯

  • events β€” Provides access to Pithub::Events.
  • gists β€” Provides access to Pithub::Gists.
  • git_data β€” Provides access to Pithub::GitData.
  • issues β€” Provides access to Pithub::Issues.
  • markdown β€” Provides access to Pithub::Markdown.
  • orgs β€” Provides access to Pithub::Orgs.
  • pull_requests β€” Provides access to Pithub::PullRequests.
  • repos β€” Provides access to Pithub::Repos.
my $legacy_search  = $p->search(search_api => 'legacy');
my $v3_search      = $p->search(search_api => 'v3');
my $default_search = $p->search;

Provides access to Pithub::Search and Pithub::SearchV3. And here's the tea: when you don't pass a "search_api" option, the value it uses is whatever you gave the "search_api" attribute. Default behavior, no surprises. ✨

🫢 users 🫢

  • users β€” Provides access to Pithub::Users.

πŸ“š DOCUMENTATION πŸ“š

Ngl, a lot of the Pithub documentation has been taken directly from the genuinely great API documentation at Github β€” http://developer.github.com/v3/. Please also read the docs over there, because it might be more complete and more up-to-date. That's not a drag, that's just facts. πŸ™ˆ

Also: Pithub::Base contains documentation for attributes inherited by all Pithub modules. So if you're wondering where an attribute came from, check there first, bestie. πŸ¦‹


⚠️ WARNING ⚠️

Pithub, as well as the Github v3 API at http://developer.github.com/v3/, are still under development. So like… there might be things broken on both sides. πŸ’€ Besides that, it's possible that the API will change. This applies to Pithub itself as well as the Github v3 API at http://developer.github.com/v3/.

Real talk: nothing here is set in stone. Guard your expectations accordingly. 🫢

🌟 CONTRIBUTE 🌟

This module is hosted on Github at https://github.com/plu/Pithub, so feel free to fork it and send pull requests. Queen behavior only. πŸ‘‘

There are two different kinds of test suites:

  1. One is just checking the HTTP requests that are created by the method calls, without actually sending them. Chill, safe, no drama.
  2. The second one is sending real requests to the Github API.

If you want to contribute to this project, I highly recommend running the live tests on a test account, because it will generate a lot of activity. Not me accidentally spamming my whole main account β€” use the burner, bestie. 😭


🧚 MODULES 🧚

There are different ways of using the Pithub library. You can either use the main module Pithub to get access to all the other modules, like Pithub::Repos for example. Or you can use Pithub::Repos directly and create an instance of it. All modules accept the same attributes, either in the constructor or later by calling the setters.

Besides that, there are other modules involved. Every method call which maps directly to a Github API call returns a Pithub::Result object. This contains everything interesting about the response returned from the API call. It's giving little wrapped gift. 🎁

Pithub::Base might be interesting for two reasons:

  • The list of attributes which all modules accept.
  • The request method: In case Github adds a new API call which is not supported yet by Pithub, the request method can be used directly to perform this new API call β€” there's some documentation on how to use it.
    • Pithub::Events

See also: http://developer.github.com/v3/events/

my $events = Pithub->new->events;
my $events = Pithub::Events->new;
  • Pithub::Gists

See also: http://developer.github.com/v3/gists/

my $gists = Pithub->new->gists;
my $gists = Pithub::Gists->new;
  • Pithub::Gists::Comments

See also: http://developer.github.com/v3/gists/comments/

my $comments = Pithub->new->gists->comments;
my $comments = Pithub::Gists->new->comments;
my $comments = Pithub::Gists::Comments->new;
  • Pithub::GitData

See also: http://developer.github.com/v3/git/

my $git_data = Pithub->new->git_data;
my $git_data = Pithub::GitData->new;
  • Pithub::GitData::Blobs

See also: http://developer.github.com/v3/git/blobs/

my $blobs = Pithub->new->git_data->blobs;
my $blobs = Pithub::GitData->new->blobs;
my $blobs = Pithub::GitData::Blobs->new;
  • Pithub::GitData::Commits

See also: http://developer.github.com/v3/git/commits/

my $commits = Pithub->new->git_data->commits;
my $commits = Pithub::GitData->new->commits;
my $commits = Pithub::GitData::Commits->new;
  • Pithub::GitData::References

See also: http://developer.github.com/v3/git/refs/

my $references = Pithub->new->git_data->references;
my $references = Pithub::GitData->new->references;
my $references = Pithub::GitData::References->new;
  • Pithub::GitData::Tags

See also: http://developer.github.com/v3/git/tags/

my $tags = Pithub->new->git_data->tags;
my $tags = Pithub::GitData->new->tags;
my $tags = Pithub::GitData::Tags->new;
  • Pithub::GitData::Trees

See also: http://developer.github.com/v3/git/trees/

my $trees = Pithub->new->git_data->trees;
my $trees = Pithub::GitData->new->trees;
my $trees = Pithub::GitData::Trees->new;
  • Pithub::Issues

See also: http://developer.github.com/v3/issues/

my $issues = Pithub->new->issues;
my $issues = Pithub::Issues->new;
  • Pithub::Issues::Assignees

See also: http://developer.github.com/v3/issues/assignees/

my $assignees = Pithub->new->issues->assignees;
my $assignees = Pithub::Issues->new->assignees;
my $assignees = Pithub::Issues::Assignees->new;
  • Pithub::Issues::Comments

See also: http://developer.github.com/v3/issues/comments/

my $comments = Pithub->new->issues->comments;
my $comments = Pithub::Issues->new->comments;
my $comments = Pithub::Issues::Comments->new;
  • Pithub::Issues::Events

See also: http://developer.github.com/v3/issues/events/

my $events = Pithub->new->issues->events;
my $events = Pithub::Issues->new->events;
my $events = Pithub::Issues::Events->new;
  • Pithub::Issues::Labels

See also: http://developer.github.com/v3/issues/labels/

my $labels = Pithub->new->issues->labels;
my $labels = Pithub::Issues->new->labels;
my $labels = Pithub::Issues::Labels->new;
  • Pithub::Issues::Milestones

See also: http://developer.github.com/v3/issues/milestones/

my $milestones = Pithub->new->issues->milestones;
my $milestones = Pithub::Issues->new->milestones;
my $milestones = Pithub::Issues::Milestones->new;
  • Pithub::Orgs

See also: http://developer.github.com/v3/orgs/

my $orgs = Pithub->new->orgs;
my $orgs = Pithub::Orgs->new;
  • Pithub::Orgs::Members

See also: http://developer.github.com/v3/orgs/members/

my $members = Pithub->new->orgs->members;
my $members = Pithub::Orgs->new->members;
my $members = Pithub::Orgs::Members->new;
  • Pithub::Orgs::Teams

See also: http://developer.github.com/v3/orgs/teams/

my $teams = Pithub->new->orgs->teams;
my $teams = Pithub::Orgs->new->teams;
my $teams = Pithub::Orgs::Teams->new;
  • Pithub::PullRequests

See also: http://developer.github.com/v3/pulls/

my $pull_requests = Pithub->new->pull_requests;
my $pull_requests = Pithub::PullRequests->new;
  • Pithub::PullRequests::Comments

See also: http://developer.github.com/v3/pulls/comments/

my $comments = Pithub->new->pull_requests->comments;
my $comments = Pithub::PullRequests->new->comments;
my $comments = Pithub::PullRequests::Comments->new;
  • Pithub::PullRequests::Reviewers

See also: https://docs.github.com/en/rest/reference/pulls#review-requests

And for the reviewers, the code is literally:

my $reviewers = Pithub->new->pull_requests->reviewers;
my $reviewers = Pithub::PullRequests->new->reviewers;
my $reviewers = Pithub::PullRequests::Reviewers->new;
  • Pithub::Repos β€” the repos hub, lowkey the main character of your GitHub adventures.

See also: <http://developer.github.com/v3/repos/>

my $repos = Pithub->new->repos;
my $repos = Pithub::Repos->new;
  • Pithub::Repos::Collaborators β€” for when you need to see who's on the team, bestie.

See also: <http://developer.github.com/v3/repos/collaborators/>

my $collaborators = Pithub->new->repos->collaborators;
my $collaborators = Pithub::Repos->new->collaborators;
my $collaborators = Pithub::Repos::Collaborators->new;
  • Pithub::Repos::Commits β€” all the commit tea, fr fr.

See also: <http://developer.github.com/v3/repos/commits/>

my $commits = Pithub->new->repos->commits;
my $commits = Pithub::Repos->new->commits;
my $commits = Pithub::Repos::Commits->new;
  • Pithub::Repos::Contents β€” peek inside the repo files, no cap.

See also: <http://developer.github.com/v3/repos/contents/>

my $contents = Pithub->new->repos->contents;
my $contents = Pithub::Repos->new->contents;
my $contents = Pithub::Repos::Contents->new;
  • Pithub::Repos::Downloads β€” okay so this one is deprecated, so pay attention.
⚠️ Github says: The Downloads API (described below) was deprecated on December 11, 2012. It will be removed at a future date. We recommend using Pithub::Repos::Releases instead.

See also: <http://developer.github.com/v3/repos/downloads/>

my $downloads = Pithub->new->repos->downloads;
my $downloads = Pithub::Repos->new->downloads;
my $downloads = Pithub::Repos::Downloads->new;
  • Pithub::Repos::Forks β€” fork it and make it your own, periodt.

See also: <http://developer.github.com/v3/repos/forks/>

my $forks = Pithub->new->repos->forks;
my $forks = Pithub::Repos->new->forks;
my $forks = Pithub::Repos::Forks->new;
  • Pithub::Repos::Keys β€” deploy keys, very secure, very demure.

See also: <http://developer.github.com/v3/repos/keys/>

my $keys = Pithub->new->repos->keys;
my $keys = Pithub::Repos->new->keys;
my $keys = Pithub::Repos::Keys->new;
  • Pithub::Repos::Releases β€” the release era, iconic.

See also: <http://developer.github.com/v3/repos/releases/>

my $releases = Pithub->new->repos->releases;
my $releases = Pithub::Repos->new->releases;
my $releases = Pithub::Repos::Releases->new;

Note that Pithub::Repos::Releases requires Boolean values for some calls. See Pithub::Repos::Releases for details.

  • Pithub::Repos::Releases::Assets β€” the assets that come with your releases, slay.

See also: <http://developer.github.com/v3/repos/releases/>

my $assets = Pithub->new->repos->releases->assets;
my $assets = Pithub::Repos->new->releases->assets;
my $assets = Pithub::Repos::Releases->new->assets;
my $assets = Pithub::Repos::Releases::Assets->new;
  • Pithub::Repos::Stats β€” stats, numbers, the data vibes.

See also: <http://developer.github.com/v3/repos/statistics/>

my $watching = Pithub->new->repos->stats;
my $watching = Pithub::Repos->new->stats;
my $watching = Pithub::Repos::Stats->new;
  • Pithub::Repos::Statuses β€” status updates, keeping you in the loop.

See also: <http://developer.github.com/v3/repos/statuses/>

my $watching = Pithub->new->repos->statuses;
my $watching = Pithub::Repos->new->statuses;
my $watching = Pithub::Repos::Statuses->new;
  • Pithub::Repos::Watching β€” watch the repo, be a secret admirer.

See also: <http://developer.github.com/v3/repos/watching/>

my $watching = Pithub->new->repos->watching;
my $watching = Pithub::Repos->new->watching;
my $watching = Pithub::Repos::Watching->new;
  • Pithub::Users β€” all about the users, the people, the icons.

See also: <http://developer.github.com/v3/users/>

my $users = Pithub->new->users;
my $users = Pithub::Users->new;
  • Pithub::Users::Emails β€” emails, but make it GitHub.

See also: <http://developer.github.com/v3/users/emails/>

my $emails = Pithub->new->users->emails;
my $emails = Pithub::Users->new->emails;
my $emails = Pithub::Users::Emails->new;
  • Pithub::Users::Followers β€” followers, the fan club.

See also: <http://developer.github.com/v3/users/followers/>

my $followers = Pithub->new->users->followers;
my $followers = Pithub::Users->new->followers;
my $followers = Pithub::Users::Followers->new;
  • Pithub::Users::Keys β€” user keys, keep it locked.

See also: <http://developer.github.com/v3/users/keys/>

my $keys = Pithub->new->users->keys;
my $keys = Pithub::Users->new->keys;
my $keys = Pithub::Users::Keys->new;

🌟 CONTRIBUTORS 🌟

Shoutout to these absolute legends who made this happen:

  • Andreas Marienborg
  • Alessandro Ghedini
  • Michael G Schwern

πŸ‘‘ AUTHOR πŸ‘‘

The one and only: Johannes Plunien <plu@cpan.org> β€” bow down.


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.


And that's the tea, bestie! This page is from perl v5.40.1, dated 2025-06-08, and it's the Pithub(3pm) manual. Stay iconic! πŸ’…βœ¨

πŸ“¦ where this page comes from