NAME

Regru::API - Perl bindings for Reg.ru API v2

build status

VERSION

version 0.042

SYNOPSIS

my $client = Regru::API->new(
    username => 'test',
    password => 'test',
);

# trivial API request
my $resp = $client->nop;

if ($resp->is_success) {
    print $response->get('user_id');
}
else {
    print "Error code: " . $resp->error_code . ", Error text: " . $resp->error_text;
}

DESCRIPTION

Regru::API implements simplified access to the REG.API v2 provided by REG.RU LLC. This is a JSON-driven implementation. Input/output request data will transforms from/to JSON transparently.

Rate limiting

Rate limiting in version 2 of the REG.API is considered on a per-user and per-ip basic. The REG.API methods have not divided into groups by limit level. There is no difference between them. At the moment REG.API v2 allows to execute 1200 requests per-user and per-ip within 1 hour window. Both limits are acting at the same time. If the limits has exceeded then REG.API sets the error code (depends on kind of) to IP_EXCEEDED_ALLOWED_CONNECTION_RATE or ACCOUNT_EXCEEDED_ALLOWED_CONNECTION_RATE which might be checked via attribute error_code.

The following tips are there might helps to reduce the possibility of being rate limited:

Categories (namespaces)

REG.API methods are divided into categories (namespaces). When you wish to make an API request to some REG.API method, that belongs to some namespace (category) you should get a namespace handler (defined as trivial client's method):

# suppose we already have a client
$client->user->nop;

# or like this
$zone = $client->zone;
$zone->register_ns(...);

At the moment there are the following namespaces:

Methods accessibility

All REG.API methods can be divided into categories of accessibility. On manual pages of this distibution accessibility marked by scope tag. At the moment the following categories of accessibility present:

Request parameters

Each API request should contains a set of parameters. There are the following parameters:

Response parameters

Response parameters of the API request automatically handles by Regru::API::Response module. There is no reasons to do some addtional work on them. Each response may contains the following set of fileds:

Access to REG.API in test mode

REG.RU LLC provides an access to REG.API in test mode. For this, might be used a test account with username and password equals to test.

my $client = Regru::API->new(username => 'test', password => 'test');
# we're in test mode now
$client->domain->get_prices;

In the test mode REG.API engine (at server-side) handles API request: ensures necessary checks of input parameters, produces response but actually does not perform any real actions/changes.

Also, for debugging purposes REG.API provides a special set of methods allows to ensure the remote system for availability without workload at minimal response time. Each namespace has method called nop for that.

METHODS

new

Creates a client instance to interract with REG.API.

my $client = Regru::API->new(
    username => 'Rassilon',
    password => 'You die with me, Doctor!'
);

my $resp = $client->user->get_balance;

print $resp->get('prepay') if $resp->is_success;

# another cool code...

Available options:

user

Returns a handler to access to REG.API user account management methods. See Regru::API::User.

domain

Returns a handler to access to REG.API domain name management methods. See Regru::API::Domain.

zone

Returns a handler to access to REG.API DNS resource records management methods. See Regru::API::Zone.

service

Returns a handler to access to REG.API service management methods. See Regru::API::Service.

folder

Returns a handler to access to REG.API folder management methods. See Regru::API::Folder.

bill

Returns a handler to access to REG.API invoice management methods. See Regru::API::Bill.

namespace_handlers

Creates shortcuts to REG.API categories (namespaces). Used internally.

REG.API METHODS

nop

For testing purposes. Scope: everyone. Typical usage:

$resp = $client->nop;

Answer will contains an user_id and login fields.

More info at Common functions: nop.

reseller_nop

Similar to previous one but only for partners. Scope: partners. Typical usage:

$resp = $client->reseller_nop;

Answer will contains an user_id and login fields.

More info at Common functions: nop.

get_user_id

Get the identifier of the current user. Scope: clients. Typical usage:

$resp = $client->get_user_id;

Answer will contains an user_id field.

More info at Common functions: nop.

get_service_id

Get service or domain name identifier by its name. Scope: clients. Typical usage:

$resp = $client->get_service_id(
    domain_name => 'teselecta.ru',
);

Answer will contains a service_id field or error code if requested domain name/service not found.

More info at Common functions: nop.

SEE ALSO

Regru::API::Bill

Regru::API::Domain

Regru::API::Folder

Regru::API::Service

Regru::API::User

Regru::API::Zone

Regru::API::Response

REG.API Common functions

REG.API Common error codes

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/regru/regru-api-perl/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHORS

COPYRIGHT AND LICENSE

This software is copyright (c) 2013 by REG.RU LLC.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.