Net::GitHub(3pm)

πŸ“¦
version 1.05 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– Net::GitHub β€” the Perl interface for github.com, bestie πŸ’–

okay so you want to talk to github.com from Perl? bestie, you have come to the right manual page. this is Net::GitHub, a perl manual page (section 3pm, user contributed, as the top of the page says). sit down, grab a strawberry πŸ“, and let's get into it.


✨ SYNOPSIS ✨

use Net::GitHub;

my $github = Net::GitHub->new(  # Net::GitHub::V3
    login => 'fayland', pass => 'secret'
);

# If you use two factor authentication you can pass in the OTP. Do
# note that OTPs expire quickly and you will need to generate an oauth
# token to do anything non-trivial.
my $github = Net::GitHub->new(
    login =>   'fayland',
    pass =>    'secret',
    otp =>     '123456',
);

# Pass api_url for GitHub Enterprise installations. Do not include a
# trailing slash
my $github = Net::GitHub->new(  # Net::GitHub::V3
    login =>   'fayland',
    pass =>    'secret',
    api_url => 'https://gits.aresweet.com/api/v3'
);

# suggested
# use OAuth to create token with user/pass
my $github = Net::GitHub->new(  # Net::GitHub::V3
    access_token => $token
);

# L<Net::GitHub::V3::Users>
my $user = $github->user->show('nothingmuch');
$github->user->update( bio => 'Just Another Perl Programmer' );

# L<Net::GitHub::V3::Repos>
my @repos = $github->repos->list;
my $rp = $github->repos->create( {
    "name" => "Hello-World",
    "description" => "This is your first repo",
    "homepage" => "https://github.com"
} );

so yeah. you make a $github object, you call methods on it, magic happens. πŸ’…


🌸 DESCRIPTION 🌸

<http://github.com> is a popular git host. like, the popular git host. main character energy, honestly. πŸ‘‘

this distribution provides easy methods to access GitHub via their APIs. that's it, that's the whole vibe.

check <http://developer.github.com/> for more details of the GitHub APIs. that's where the actual API tea lives.

read Net::GitHub::V3 for API usage.

read Net::GitHub::V4 for GitHub GraphQL API. (yes, GraphQL, we love a modern queen ✨)

if you prefer object oriented way, Pithub is 'There is more than one way to do it'. TMTOWTDI baby, that's the Perl motto, no cap.

πŸŽ€ FAQ πŸŽ€

  • create access_token for Non-Web Application
my $gh = Net::GitHub::V3->new( login => 'fayland', pass => 'secret' );
my $oauth = $gh->oauth;
my $o = $oauth->create_authorization( {
    scopes => ['user', 'public_repo', 'repo', 'gist'], # just ['public_repo']
    note   => 'test purpose',
} );
print $o->{token};

after create the token, you can use it without your password publicly written

my $github = Net::GitHub->new(
    access_token => $token, # from above
);

like, you literally print out the token once and then never have to hardcode your password anywhere public again. that's the whole point, bestie, protect your secrets 🫢


πŸ¦‹ Git πŸ¦‹

<http://github.com/fayland/perl-net-github/>

go look at the source, it's right there πŸ‘‘


⭐ SEE ALSO ⭐

Pithub

(they do the object-oriented thing, iykyk)


πŸ’œ AUTHOR πŸ’œ

Fayland Lam, "<fayland at gmail.com>"

Everyone who is listed in Changes.

(the whole squad, fr fr 🫢)


Copyright 2009-2012 Fayland Lam all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

periodt. πŸ’…


okay bestie that's the whole page, you're officially a Net::GitHub girlie now πŸ’– this was Net::GitHub(3pm) from perl v5.36.0, dated 2022-10-08 β€” go forth and slay those API calls βœ¨πŸŽ€πŸ¦‹

πŸ“¦ where this page comes from