zpmlabs/godaddy-php-sdk

Unofficial PHP SDK for GoDaddy API.

1.0.0 2025-08-29 11:25 UTC

This package is auto-updated.

Last update: 2025-08-29 11:30:17 UTC


README

PHP Version License Tests

Unofficial PHP SDK for GoDaddy API. A comprehensive library that provides easy-to-use interfaces for all GoDaddy API services.

Features

  • Complete API Coverage: Support for all GoDaddy API services with full implementation
  • Type Safety: Full PHP 8.2+ type hints and strict typing
  • PSR-4 Autoloading: Modern PHP standards compliance
  • Comprehensive Testing: 290+ tests with full coverage using Pest PHP
  • Multiple API Versions: Complete support for both v1 and v2 APIs
  • DTO Pattern: Clean data transfer objects for all API requests/responses
  • Exception Handling: 50+ specific exception classes for different error scenarios
  • Enum Support: Comprehensive enum classes for type-safe values
  • DNSSEC Support: Full DNSSEC record management in v2 API
  • Advanced Domain Management: Complete domain lifecycle management

Requirements

  • PHP 8.2 or higher
  • Guzzle HTTP Client 7.0 or higher
  • Composer

Installation

Via Composer (Recommended)

composer require zpmlabs/godaddy-php-sdk

Manual Installation

  1. Clone the repository:
git clone https://github.com/your-username/godaddy-php-sdk.git
cd godaddy-php-sdk
  1. Install dependencies:
composer install

Quick Start

Basic Usage

<?php

require_once 'vendor/autoload.php';

use GoDaddy\GoDaddy;

// Initialize the SDK with your API credentials
$godaddy = new GoDaddy(
    apiKey: 'your-api-key',
    apiSecret: 'your-api-secret',
    baseUrl: 'https://api.ote-godaddy.com' // Use production URL for live
);

// Use any service
$domains = $godaddy->domains();
$certificates = $godaddy->certificates();
$shoppers = $godaddy->shoppers();

Example: List Domains (v1)

<?php

use GoDaddy\Services\Domains\v1\DomainsService;
use GoDaddy\Services\Domains\v1\DTO\ListDomainsQueryData;

$domainsService = new DomainsService('api-key', 'api-secret', 'https://api.ote-godaddy.com');

try {
    $queryData = new ListDomainsQueryData();
    $queryData->limit = 100;
    $queryData->statusGroups = ['ACTIVE'];
    
    $domains = $domainsService->listDomains($queryData);
    foreach ($domains as $domain) {
        echo "Domain: {$domain['domain']}\n";
    }
} catch (GoDaddy\Exceptions\ServiceException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Example: Get Domain Details (v2)

<?php

use GoDaddy\Services\Domains\v2\DomainsService;
use GoDaddy\Services\Domains\v2\DTO\GetDomainDetailsQueryData;

$domainsService = new DomainsService('api-key', 'api-secret', 'https://api.ote-godaddy.com');

try {
    $queryData = new GetDomainDetailsQueryData();
    $queryData->includes = ['contacts', 'nameServers'];
    
    $domainDetails = $domainsService->getDomainDetails('customer123', 'example.com', $queryData);
    echo "Domain: {$domainDetails->domain}\n";
    echo "Status: {$domainDetails->status}\n";
} catch (GoDaddy\Exceptions\ServiceException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Example: Manage DNSSEC Records (v2)

<?php

use GoDaddy\Services\Domains\v2\DomainsService;
use GoDaddy\Services\Domains\v2\DTO\DnssecRecordData;
use GoDaddy\Services\Domains\v2\Enums\DnssecAlgorithm;

$domainsService = new DomainsService('api-key', 'api-secret', 'https://api.ote-godaddy.com');

try {
    $record = new DnssecRecordData(
        DnssecAlgorithm::RSA_SHA256->value,
        'digest123',
        '1',
        '12345'
    );
    
    $domainsService->addDnssecRecords('customer123', 'example.com', [$record]);
    echo "DNSSEC record added successfully\n";
} catch (GoDaddy\Exceptions\ServiceException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Example: Create Certificate

<?php

use GoDaddy\Services\Certificates\v1\CertificatesService;
use GoDaddy\Services\Certificates\v1\DTO\{
    CertificateCreateData,
    ContactData,
    AddressData,
    OrganizationData
};

$certificatesService = new CertificatesService('api-key', 'api-secret', 'https://api.ote-godaddy.com');

$contactData = new ContactData(
    'John Doe',
    'john@example.com',
    '123456789',
    '123 Main St',
    'City',
    'State',
    '12345',
    'US'
);

$addressData = new AddressData(
    '123 Main St',
    '',
    'City',
    'US',
    '12345',
    'State'
);

$orgData = new OrganizationData(
    $addressData,
    'Example Corp',
    'Example Corporation',
    '123456789',
    'Registration Agent',
    'REG123456'
);

$createData = new CertificateCreateData(
    'https://callback.example.com',
    'example.com',
    $contactData,
    'CSR_STRING',
    false,
    $orgData,
    12,
    'DV',
    'ROOT_TYPE',
    'SLOT_SIZE',
    ['example.com']
);

try {
    $result = $certificatesService->createCertificate($createData);
    echo "Certificate created: " . $result['certificateId'] . "\n";
} catch (GoDaddy\Exceptions\ServiceException $e) {
    echo "Error: " . $e->getMessage() . "\n";
}

Available Services

The SDK provides access to all GoDaddy API services. Each service has its own documentation with detailed usage examples:

Core Services

New Features & Improvements

🆕 Complete v2 Domains API Implementation

  • 40+ new methods for advanced domain management
  • DNSSEC support with full record management
  • Advanced domain transfers with granular control
  • Domain forwards management
  • Notification system with opt-in/opt-out
  • Domain actions tracking
  • Registration schemas for TLDs
  • Maintenance and usage tracking

🆕 Enhanced v1 Domains API

  • 3 new enums added for complete API coverage
  • DomainSuggestionSource enum for domain suggestions
  • DnsRecordType enum for DNS record types
  • CheckType enum enhanced with lowercase variants

🆕 Comprehensive Testing

  • 290+ tests with full coverage
  • 658 assertions ensuring reliability
  • Complete unit tests for all DTOs and Enums
  • Feature tests for all service methods

🆕 Enhanced Exception Handling

  • 50+ specific exception classes for different error scenarios
  • Proper error categorization for better debugging
  • Comprehensive error messages with context

Configuration

API Credentials

You'll need to obtain API credentials from GoDaddy:

  1. Log in to your GoDaddy Developer account
  2. Create a new application
  3. Get your API Key and API Secret
  4. Use the appropriate base URL:
    • Production: https://api.godaddy.com
    • OTE (Testing): https://api.ote-godaddy.com

Environment Variables

For security, store your credentials in environment variables:

export GODADDY_API_KEY="your-api-key"
export GODADDY_API_SECRET="your-api-secret"
export GODADDY_BASE_URL="https://api.ote-godaddy.com"

Then use them in your code:

$godaddy = new GoDaddy(
    apiKey: $_ENV['GODADDY_API_KEY'],
    apiSecret: $_ENV['GODADDY_API_SECRET'],
    baseUrl: $_ENV['GODADDY_BASE_URL']
);

Error Handling

The SDK provides specific exception classes for different error scenarios:

use GoDaddy\Exceptions\{
    ServiceException,
    NotFoundException,
    ForbiddenException,
    RateLimitExceededException,
    InternalServerErrorException
};

try {
    $result = $service->someMethod();
} catch (NotFoundException $e) {
    // Resource not found (404)
    echo "Resource not found: " . $e->getMessage();
} catch (ForbiddenException $e) {
    // Access denied (403)
    echo "Access denied: " . $e->getMessage();
} catch (RateLimitExceededException $e) {
    // Rate limit exceeded (429)
    echo "Rate limit exceeded: " . $e->getMessage();
} catch (ServiceException $e) {
    // General service error
    echo "Service error: " . $e->getMessage();
}

Testing

Run the test suite:

# Run all tests
composer test

# Run tests with coverage
./vendor/bin/pest --coverage

# Run specific test file
./vendor/bin/pest tests/Feature/v1/DomainsServiceTest.php
./vendor/bin/pest tests/Feature/v2/DomainsServiceTest.php

# Run all tests (290 tests, 658 assertions)
./vendor/bin/pest

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

Development Setup

# Clone the repository
git clone https://github.com/your-username/godaddy-php-sdk.git
cd godaddy-php-sdk

# Install dependencies
composer install

# Run tests
composer test

License

This project is licensed under the MIT License - see the LICENSE file for details.

Support

  • Documentation: Each service has detailed documentation in its respective README file
  • Issues: Report bugs and feature requests on GitHub Issues
  • Discussions: Join the conversation on GitHub Discussions

Changelog

Latest Updates

  • Complete v2 Domains API implementation (40+ new methods)
  • Enhanced v1 Domains API (3 new enums)
  • Comprehensive testing (290+ tests, 658 assertions)
  • DNSSEC support with full record management
  • Advanced domain transfers with granular control
  • Domain forwards management
  • Notification system implementation
  • Enhanced exception handling (50+ specific exceptions)

See CHANGELOG.md for a complete list of changes and version history.

Acknowledgments

  • GoDaddy for providing the API
  • The PHP community for excellent tools and libraries
  • All contributors who help improve this SDK

Note: This is an unofficial SDK and is not affiliated with or endorsed by GoDaddy Inc.