neoflow/github-api-client

This package is not installable via Composer 1.x, please make sure you upgrade to Composer 2+. Read more about our Composer 1.x deprecation policy.

GitHub API Client

1.0.0-beta 2020-06-12 15:47 UTC

This package is auto-updated.

Last update: 2021-10-12 23:20:46 UTC


README

An easy-to-use, readonly client for the GitHub API v3, written in PHP with file-based cache support.

Please note The GitHub API-Client only supports unauthenticated GET requests, with a rate limit for up to 60 requests per hour. Read more here about the rate limit.

If you need a full featured client, with support for authenticated requests, please try out the well tested and documented php-github-api.

Requirement

  • PHP >= 7.3
  • JSON extension for PHP
  • cURL extension for PHP

The required extensions for PHP are usually enabled by default.

Install

You have 2 options to install the GitHub API-Client.

Via Composer:

composer require neoflow/github-api-client

Or manually download the latest release from here and use it however you want.

Basic usage

// Include vendor autoload
require_once '../vendor/autoload.php';

// Initialize GitHub API-Client with your identifier
$client = new \Neoflow\GitHubApiClient('Neoflow');

// Send get request to the GitHub API
$response = $client->get('/repos/Neoflow/GitHub-API-Client/releases/latest');

// Check response and put out tag name (version) of the latest release
if ($response['header']['http_code'] === 200) {
    echo 'Latest release: ' . $response['content']['tag_name'];
}

Important You MUST set an identifier, which will be sent by the client as a User-Agent header. Requests with no User-Agent header will be rejected by the GitHub API. GitHub want you to you use your GitHub username, or the name of your application or porject as identifier. This allows GitHub to contact you, if there are any problems. Read more here about the User-Agent header restriction.

Advanced configuration

The GitHub API-Client supports an optional array for custom options as a 2nd constructor argument. Please take a look into the code by yourself, if you want to know more. The code should be easy to understand and self-explanatory.

For more information about the GitHub API v3, please visit the official guidelines.

Author(s)

License

This piece of software is unlicensed. Use it however you like.

Made in Switzerland with 🧀