Search by

sdk-generator / dog-ceo-sdk

dmorenof

Unofficial PHP SDK for the Dog API (dog.ceo): breeds, sub-breeds and random dog pictures. Generated from a recorded browser session (HAR).

Package info

github.com/sdk-generator/dog-ceo-sdk

pkg:composer/sdk-generator/dog-ceo-sdk

Statistics

Installs: 1

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v0.1.1 2026-12-03 20:11 UTC

This package is auto-updated.

Last update: 2026-12-03 22:16:44 UTC


README

License: MIT PHP 8.4+ PHPStan level max Packagist

Dog breeds and pictures from the Dog API as typed PHP, generated from a recorded browser session.

All breeds and sub-breeds, and random or full lists of pictures for any breed, from the Dog API. Free, no key.

Unofficial. Not affiliated with, endorsed by or supported by Dog CEO or the Dog API. See NOTICE.md.

Why this SDK

  • Generated from real traffic. The Dog API publishes no machine-readable description; the generator read an HTTP Archive of real calls and found the breed, the sub-breed and the count in the paths (/breed/{breed}/{subBreed}/images/random/{count}).
  • Free API without a key: install and call.
  • Generated from a recorded browser session (HAR), never edited by hand. src/ is produced by sdk-generator from the HTTP Archive (HAR) of real calls described in contract/SOURCE.md, on top of the shared sdk-runtime: when the source changes you regenerate, you do not patch.
  • Typed end to end. 11 operations and 6 typed request, answer and model classes. A request is a model whose fields are checked where you assign them (PHP 8.4 property hooks); an answer is a model; a list is a typed collection. PHPStan at the maximum level reports no error on the whole SDK.
  • One way to fail. An HTTP answer the contract does not declare as success is an ApiException that keeps the raw response and, when the API documents it, the decoded error as a model. Network failures keep their own type.
  • Production controls included. PSR-18 HTTP client (Guzzle by default), timeouts (30 s / 10 s by default), retries with Retry-After, redirect policy, middleware and per-environment servers, all in one Configuration object.

Install

PHP 8.4 or later.

composer require sdk-generator/dog-ceo-sdk

Quick start

<?php
use DogCeoSDK\Breed\ByBreed\BySubBreed\Images\Random as SubBreedRandom;
use DogCeoSDK\Breed\ByBreed\Images;
use DogCeoSDK\Breeds\Image\Random;
use DogCeoSDK\Configuration;
use DogCeoSDK\DogCeoSDK;
use DogCeoSDK\PathParams\Breed\ByBreed\BySubBreed\Images\Random as SubBreed;

DogCeoSDK::configure(new Configuration());

echo json_encode(Random::getByCount(3)->message), "\n";       // three random pictures
echo json_encode(Images::get('hound')->message), "\n";        // every hound picture

$afghan = new SubBreed();
$afghan->breed = 'hound';
$afghan->subBreed = 'afghan';
echo json_encode(SubBreedRandom::get($afghan)->message), "\n";  // one Afghan hound

The same example is in examples/quickstart.php. Every operation is listed in docs/OPERATIONS.md.

What it covers

11 operations. The biggest areas:

Area Operations
breed 7
breeds 4

Handling errors

use Dmorenof\SdkRuntime\ApiException;

try {
    // ... any call from the quick start
} catch (ApiException $e) {
    echo $e->response->status, "\n";   // the HTTP status
    echo $e->response->body, "\n";     // the raw body, always kept
    var_dump($e->error);                // the decoded error model, when the API documents one
}

Configuration

Configuration is the only place to set anything: baseUrl, securityCredentials, headers, timeout, connectTimeout, retryPolicy, redirectPolicy, middleware, httpClient (any PSR-18 client), serverVariables. Use Client::connect($configuration) instead of the static facades when you need several independent connections.

Good to know

  • Every answer is {"message": ..., "status": "success"}; message is a picture URL, a list of them or the breed map, depending on the call.
  • Generated from what the capture shows: an endpoint not used in it is not in the SDK.
  • Version 0.1.0 is a first release: the API of the SDK follows the source description, and a regenerated one can rename classes. Pin a version.

Documentation

License

MIT, see LICENSE.md. The license covers this SDK's code, not the API, its trademarks or its terms: see NOTICE.md.