Welcome

The CentralNic Toolkit is CentralNic's system for instantaneous Registry-Registrar Communications. Registrars can use this system to register and modify domain names in real time, with no delays for human intervention or e-mail processing. The toolkit also provides advanced and efficient methods for searching for and querying domain names and whois records, and retrieving account information.

All the software developed for the Toolkit system is Open Source, and is developed in a participatory manner, relying on cooperation with our user base. Users of the software are encouraged to submit bugs, suggestions, feature requests and patches.

News

You can subscribe to Toolkit News using the RSS Feed.

Sample Code: how to automatically prepare a payment batch

Posted by Gavin Brown on Thursday, May 1, 2008 at 10:23 UTC

Here's some sample code showing what you can do with our WWW::CNic Perl library. This script uses two functions — list_outstanding_domains and submit_payment_batch — to automatically prepare a payment batch for all domain names that are 45 days or more overdue.

There are a few ways this script could be customised: for example, to send an email to your finance team to instruct them to initiate a wire transfer for the payment. In a production environment, you'd also want to log what you're doing and update the status of the domain names in your own database.

We hope to be able to publish more sample scripts in the future: watch this space!

#!/usr/bin/perl -w
# example script to automatically remit payment advice for oustanding
# domain names.
#
# Copyright (c) 2008 CentralNic Ltd. All rights reserved. This program is
# free software; you can redistribute it and/or modify it under the same
# terms as Perl itself.
#
use WWW::CNic;
use Date::Manip;
use strict;
use warnings;

#
# some basic variables:
#
my $registrar_id         = '';       # your registrar ID
my $password             = '';       # your registrar password (or toolkit password)
my $days                 = 45;       # threshold after which you want to remit payment for a domain
my $method               = 'BA';     # BA for a bank transfer, or CH for a check

#
# prepare the query to return all outstanding domains:
#
my $query = WWW::CNic->new(
        use_ssl         => 1,
        command         => 'list_outstanding_domains',
        username        => $registrar_id,
        password        => $password,
);

#
# execute the query and check the response for an error:
#
my $result = $query->execute;

if ($result->is_error) {
        printf(
                STDERR
                "Error retrieving outstanding domains list: %s\n",
                $result->message
        );
        exit 1;
}

#
# the domains to be paid off go in here:
#
my @domains;

#
# loop through the result:
#
foreach my $domain ($result->domains) {
     #
     # calculate how long the domain has been unpaid:
     #
     my $outstanding = int((time() - strtotime($domain->{expiry})) / 86400);

     #
     # if the 'batch' property is non-zero, then we've already
     # processed this domain, so ignore it:
     #
     next if (defined($domain->{batch}) && int($domain->{batch}) > 0);

     #
     # if the domain is above the threshold, add it to the list:
     #
     if ($outstanding >= $days) {
                printf(
                        "Adding domain '%s' to batch, as it is %d days outstanding\n",
                        $domain->{domain},
                        $outstanding
                );
                push(@domains, $domain->{domain});
        }
}

if (0 == scalar(@domains)) {
        print "No domains found, exiting normally.\n";
        exit 0;
}

printf("Submit payment advice for %d domains\n", scalar(@domains));

#
# prepare the query to submit payment advice:
#
$query = WWW::CNic->new(
        use_ssl         => 1,
        command         => 'submit_payment_batch',
        username        => $registrar_id,
        password        => $password,
);

$query->set('method', $method);
$query->set('domains', \@domains);

#
# execute the query and check the response for an error:
#
$result = $query->execute;

if ($result->is_error) {
        printf(
                STDERR
                "Error submitting payment batch: %s\n",
                $result->message
        );
        exit 1;
}

#
# display response info:
#
printf(
        "Payment Batch #%d created for %d items at %s%01.2f (plus %s%01.2f VAT)\n",
        $result->response('batch'),
        $result->response('items'),
        $result->response('currency'),
        $result->response('amount'),
        $result->response('currency'),
        $result->response('vat'),
);

#
# a PHP-like strtotime() function:
#
sub strtotime { UnixDate(ParseDate($_[0]), '%s') }

New functions and libraries

Posted by Gavin Brown on Tuesday, February 5, 2008 at 18:36 UTC

We've finally gotten round to making our web forwarding system available to users of the Toolkit. This system allows you to specify a URL to which a domain name will be forwarded, rather than being delegated to DNS servers.

Details of the new function can be found on the documentation pages for the register and modify functions, and you can also see usage information in the documentation for the Perl and PHP libraries, which have been updated today. You can download the latest releases from the downloads page.

WWW::CNic 0.24

Posted by Gavin Brown on Tuesday, July 24, 2007 at 11:39 UTC

A new version of WWW::CNic is now available from the downloads page. This release corrects an issue with the period parameter of the issue_renewals command.

New Account Management Functions

Posted by Gavin Brown on Monday, July 9, 2007 at 16:49 UTC

We have just enabled two new Toolkit functions that we think will be of great interest to our registrars:

  • The list_outstanding_domains allows you to retrieve a list of all outstanding invoice items for unpaid registrations and renewals
  • The submit_payment_batch function allows you to create a payment batch of outstanding domain items and notify us tha you're planning to remit payment via bank transfer or cheque

The upshot of this is that it is now possible for registrars to automate the process of keeping their account up-to-date, minimising the amount of human intervention.

These new functions are also available via the Perl and PHP libraries - consult the relevant cookbook for more information. The relevant releases of these libraries (0.23 for Perl and 0.0.23 for PHP) are available from the downloads page.

Finally, these functions are also available to EPP-based registrars who ordinarily cannot access Toolkit functions.

CentralNic uses these open source projects:
Slackware CentOS Apache PHP Perl MySQL