Skip to main content

NIC.RU API wrapper library

Project description

The package is a wrapper for the API of Russian DNS registrar Ru-Center (a.k.a. NIC.RU). The library provides classes for managing DNS services, zones and records.


Using pip:

pip install nic-api

If you want to use the module in your project, add this line to the project’s requirements.txt file:




To start using the API, you should get a pair of OAuth application login and password from NIC.RU. Here is the registration page:

Create an instance of nic_api.DnsApi and provide the OAuth application credentials:

from nic_api import DnsApi
oauth_config = {
    'APP_LOGIN': 'your_application_login',
    'APP_PASSWORD': 'your_application_secret'
api = DnsApi(oauth_config)


Call the authorize() method and specify the username and the password of your NIC.RU account, and a file to store the OAuth token for future use:


Now you are ready to use the API.

While the token in token_filename file is valid, you don’t need to provide neither username or password to access the API - just create an instance of the DnsApi class with the same OAuth config, and pass only token_filename to the authorize() method.

Viewing services and DNS zones

In the NIC.RU, DNS zones are located in “services”:

Usually there is one service per account. Let’s view available zones in the service MY_SERVICE:


Always check if the zone has any uncommitted changes to it before making any modifications - your commit will apply other changes too!

Getting DNS records

For viewing or modifying records, you need to specify both service and DNS zone name:

api.records('MY_SERIVCE', '')

Creating a record

To add a record, create an instance of one of the nic_api.models.DNSRecord subclasses, i.e. ARecord:

from nic_api.models import ARecord
record_www = ARecord(name='www', a='', ttl=3600)

Add this record to the zone and commit the changes:

api.add_record(record_www, 'MY_SERVICE', '')
api.commit('MY_SERVICE', '')

Deleting a record

Every record in the zone has an unique ID, and it’s accessible via property. When you got the ID, pass it to the delete_record method:

api.delete_record(100000, 'MY_SERVICE', '')
api.commit('MY_SERVICE', '')

Do not forget to always commit the changes!

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for nic-api, version 0.2.4
Filename, size File type Python version Upload date Hashes
Filename, size nic_api-0.2.4-py2.py3-none-any.whl (22.2 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page