hostmyservers / netim-rest_api
Client REST API pour Netim par HostMyServers
Installs: 1 504
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 0
Forks: 0
Open Issues: 0
pkg:composer/hostmyservers/netim-rest_api
Requires
- php: >=8.0
- guzzlehttp/guzzle: ^7.0
Requires (Dev)
- phpunit/phpunit: ^9.0
README
A Laravel package to interact with the Netim API for domain management.
Installation
You can install the package via composer:
composer require hostmyservers/netim-rest-api
Configuration
First, publish the configuration file using the following command:
php artisan vendor:publish --provider="HostMyServers\NetimRestApi\NetimServiceProvider"
This will create a config/netim.php file in your project.
Add these variables to your .env file:
NETIM_LOGIN=your_login NETIM_SECRET=your_secret NETIM_LANGUAGE=EN NETIM_API_URL=https://api.netim.com/v1/
The published configuration file will automatically use these environment variables.
Basic Usage
use HostMyServers\NetimRestApi\NetimClient; // Initialize the client $netim = new NetimClient(); // Check domain availability $availability = $netim->domain->checkDomain('example.com'); // Get domain information $domainInfo = $netim->domain->getDomainInfo('example.com'); // Update DNS servers $nameservers = [ 'ns1.example.com', 'ns2.example.com' ]; $dnsUpdate = $netim->domain->updateDNS('example.com', $nameservers); // Enable WHOIS privacy $privacy = $netim->domain->setWhoisPrivacy('example.com', true); // Get list of all domains $allDomains = $netim->domain->getDomainsList();
Error Handling
The API client throws NetimException when errors occur. You should handle these exceptions in your code:
use HostMyServers\NetimRestApi\Exceptions\NetimException; try { $domainInfo = $netim->domain->getDomainInfo('example.com'); } catch (NetimException $e) { echo "Error: " . $e->getMessage(); echo "API Error Code: " . $e->getApiErrorCode(); echo "API Error Data: " . print_r($e->getApiErrorData(), true); }
Session Management
The client automatically handles session creation and cleanup. However, you can manually manage sessions if needed:
// Check if session is active if ($netim->hasActiveSession()) { // Do something } // Force session renewal $netim->renewSession(); // Manually close session $netim->closeSession();
Available Methods
Domain Management (DomainService)
getDomainInfo(string $domain): Get domain informationcheckDomain(string $domain): Check domain availabilitycheckDomainClaim(string $domain): Check domain claimscreateDomain(string $domain, array $domainData): Register a new domaintransferDomain(string $domain, array $transferData): Transfer a domain to NetimtransferDomainTrade(string $domain, array $transferData): Transfer and trade a domainrenewDomain(string $domain, int $period): Renew a domainupdateDNS(string $domain, array $nameservers): Update DNS serverssetWhoisPrivacy(string $domain, bool $enabled): Enable/Disable WHOIS privacysetAutoRenew(string $domain, bool $enabled): Enable/Disable auto-renewalgetWhois(string $domain): Get WHOIS informationdeleteDomain(string $domain): Delete a domaingetDomainsList(): Get list of all domainssetDNSSEC(string $domain, int $enabled): Configure DNSSECsetDNSSECExt(string $domain, array $dnssecData): Configure external DNSSECsetDomainLock(string $domain, string $locked): Update domain lock statusrequestAuthCode(string $domain, int $sendtoregistrant): Request authorization coderestoreDomain(string $domain): Restore an expired domain
Zones Management (ZonesService)
initializeDnsZone(string $domain, array $options): Initialize a DNS zoneinitializeSoaRecord(string $domain, array $options): Initialize SOA recordcreateDnsZone(string $domain, array $records): Create a DNS zonedeleteDnsZone(string $domain, $records): Delete a DNS zonegetDnsRecordsList(string $domain): Get list of DNS recordscreateMailForward(string $domain, string $source, string $destination): Create an email forwarddeleteMailForward(string $domain, string $source): Delete an email forwardgetMailForwardsList(string $domain): Get list of email forwardscreateWebForward(string $domain, string $source, string $destination, array $options): Create a web forwarddeleteWebForward(string $domain, string $source): Delete a web forwardgetWebForwardsList(string $domain): Get list of web forwards
Contact Management (ContactService)
createContact(array $contactData): Create a new contactgetContact(string $contactId): Get contact informationupdateContact(string $contactId, array $contactData): Update a contactdeleteContact(string $contactId): Delete a contactgetContactList(string $field, string $filter): Get filtered list of contacts
TLD Services (TldService)
getInfo(string $tld): Get TLD informationgetPriceList(): Get TLD price list
Web Hosting (WebHostingService)
getHostingInfo(string $hostingId): Get web hosting informationcreateHosting(array $hostingData): Create a new web hosting
License
This package is open-sourced software licensed under the MIT license.