Ruby

The Ruby SDK for the GitHub REST API, generated from the same spec as the other nine.

Get the source

bash
gh repo clone octri-dev/github-ruby-showcase-sdk

The repository's README lists the toolchain and build commands for Ruby. Open it on GitHub.

Quickstart

ruby
require "github"

config = Github::ClientConfig.new
config.base_url = "https://api.github.com"
client = Github::GitHubV3REST.new(config)
result = client.search.labels(repository_id: 1, q_value: "q")
p result

Authentication

This build does not declare an authentication scheme. If the service requires a custom credential, set it through ClientAuthConfig.headers; those headers are merged into every request.

Client behavior

  • Base URL: https://api.github.com.
  • Transport: Net::HTTP.
  • Timeout: 600,000 ms per attempt.
  • Retries: up to 3 attempts for status codes 408, 409, 429, 500, 502, 503, 504, with 500-8,000 ms backoff.
  • Idempotency: enabled for POST, PATCH using Idempotency-Key.
  • Error telemetry: off. This build has no reporting endpoint and sends no error reports.

High-level operation methods return the typed response body directly. The low-level request layer returns an SdkResponse<T> envelope containing data, status, headers, request ID, latency, and attempt count.

Errors

All failure paths use a small, predictable hierarchy:

ErrorMeaning
SdkValidationErrorA request argument failed an OpenAPI constraint before network I/O.
SdkHttpErrorThe server returned a non-2xx response.
SdkNetworkErrorDNS, connection, TLS, or socket failure.
SdkTimeoutErrorThe configured per-attempt timeout elapsed.

HTTP errors expose status_code, the response body and headers, plus request_id when the server supplies one. Preserve the request ID in support logs; it is the fastest way to correlate a failed SDK call with server-side traces.

Common statuses are reported as a subclass of SdkHttpError, so a handler can catch only the one it handles: SdkBadRequestError (400), SdkUnauthorizedError (401), SdkPermissionDeniedError (403), SdkNotFoundError (404), SdkConflictError (409), SdkUnprocessableEntityError (422), SdkRateLimitError (429), SdkInternalServerError (any 5xx). Any other status is reported as SdkHttpError itself.

When the API declares a model for an error response, the SDK decodes the body into it as error.data; narrow it with is_a?. It is empty when the status declares no model or the body does not fit one. The raw body stays on the error either way, and error.decode_body(ErrorModel) decodes it into any ErrorModel by hand.