Client

class loopiase.Loopia(username, password, *, url='https://api.loopia.se/RPCSERV')

Client for the Loopia XML-RPC API.

Example:

from loopia import Loopia

client = Loopia("user@loopiaapi", "my_password")
domains = client.get_domains()
Parameters:
  • username (str)

  • password (str)

  • url (str)

reseller

Reseller-only methods. See Reseller.

add_domain(domain, *, customer_number=None)

Add an existing domain to a Loopia account.

Example:

client.add_domain("example.com")
Parameters:
  • domain (str)

  • customer_number (str | None)

Return type:

str

remove_domain(domain, *, customer_number=None)

Remove a domain from a Loopia account.

Parameters:
  • domain (str)

  • customer_number (str | None)

Return type:

str

get_domain(domain, *, customer_number=None)

Get information about a specific domain.

Example:

domain = client.get_domain("example.com")
print(domain.expiration_date, domain.paid)
Parameters:
  • domain (str)

  • customer_number (str | None)

Return type:

Domain

get_domains(*, customer_number=None)

List all domains on the account.

Example:

for domain in client.get_domains():
    print(domain.domain, domain.expiration_date)
Parameters:

customer_number (str | None)

Return type:

list[Domain]

domain_is_free(domain)

Check whether a domain is available for registration.

Returns True if the domain is free, False if occupied.

Example:

if client.domain_is_free("example.com"):
    print("Available!")
Parameters:

domain (str)

Return type:

bool

order_domain(domain, has_accepted_terms, *, customer_number=None)

Register a new domain.

The account owner must have accepted the terms and conditions at loopia.com/terms-and-conditions/ before calling this method.

Example:

client.order_domain("example.com", has_accepted_terms=True)
Parameters:
  • domain (str)

  • has_accepted_terms (bool)

  • customer_number (str | None)

Return type:

str

transfer_domain(domain, auth_code, *, customer_number=None)

Transfer a domain to Loopia from another registrar.

Example:

client.transfer_domain("example.com", auth_code="EPP-AUTH-CODE")
Parameters:
  • domain (str)

  • auth_code (str)

  • customer_number (str | None)

Return type:

str

update_dns_servers(domain, nameservers, *, customer_number=None)

Update the nameservers for a domain. At least two must be specified.

Example:

client.update_dns_servers("example.com", ["ns1.loopia.se", "ns2.loopia.se"])
Parameters:
  • domain (str)

  • nameservers (list[str])

  • customer_number (str | None)

Return type:

str

add_subdomain(domain, subdomain, *, customer_number=None)

Create a subdomain under a domain.

Example:

client.add_subdomain("example.com", "www")
Parameters:
  • domain (str)

  • subdomain (str)

  • customer_number (str | None)

Return type:

str

remove_subdomain(domain, subdomain, *, customer_number=None)

Remove a subdomain.

Parameters:
  • domain (str)

  • subdomain (str)

  • customer_number (str | None)

Return type:

str

get_subdomains(domain, *, customer_number=None)

List all subdomains for a domain.

Example:

subdomains = client.get_subdomains("example.com")
# ['@', 'www', 'mail']
Parameters:
  • domain (str)

  • customer_number (str | None)

Return type:

list[str]

add_zone_record(domain, subdomain, record, *, customer_number=None)

Add a DNS record to a subdomain.

Example:

from loopia import Record

record = Record(type="A", ttl=300, rdata="93.184.216.34")
client.add_zone_record("example.com", "@", record)
Parameters:
  • domain (str)

  • subdomain (str)

  • record (Record)

  • customer_number (str | None)

Return type:

str

get_zone_records(domain, subdomain, *, customer_number=None)

Get all DNS records for a subdomain.

Example:

for record in client.get_zone_records("example.com", "@"):
    print(record.type, record.rdata, record.ttl)
Parameters:
  • domain (str)

  • subdomain (str)

  • customer_number (str | None)

Return type:

list[Record]

update_zone_record(domain, subdomain, record, *, customer_number=None)

Update an existing DNS record. The record.record_id must be set.

Example:

record = Record(type="A", ttl=600, rdata="1.2.3.4", record_id=42)
client.update_zone_record("example.com", "@", record)
Parameters:
  • domain (str)

  • subdomain (str)

  • record (Record)

  • customer_number (str | None)

Return type:

str

remove_zone_record(domain, subdomain, record_id, *, customer_number=None)

Delete a DNS record by its ID.

Example:

client.remove_zone_record("example.com", "@", record_id=42)
Parameters:
  • domain (str)

  • subdomain (str)

  • record_id (int)

  • customer_number (str | None)

Return type:

str

get_invoice(invoice_number, *, customer_number=None)

Retrieve a specific invoice by its reference number.

Example:

invoice = client.get_invoice("INV-12345")
print(invoice.to_pay, invoice.currency)
for item in invoice.items:
    print(item.product, item.subtotal)
Parameters:
  • invoice_number (str)

  • customer_number (str | None)

Return type:

Invoice

get_unpaid_invoices(*, customer_number=None)

List all unpaid invoices on the account.

Example:

for invoice in client.get_unpaid_invoices():
    print(invoice.reference_no, invoice.to_pay, invoice.currency)
Parameters:

customer_number (str | None)

Return type:

list[Invoice]

pay_invoice_using_credits(invoice_number, *, customer_number=None)

Pay an invoice using LoopiaPREPAID credits.

Raises LoopiaError with status INSUFFICIENT_FUNDS if the balance is too low.

Parameters:
  • invoice_number (str)

  • customer_number (str | None)

Return type:

str

get_credits_amount(*, customer_number=None, with_vat=False)

Get the current LoopiaPREPAID balance.

Example:

balance = client.get_credits_amount()
print(f"Balance: {balance} SEK")
Parameters:
  • customer_number (str | None)

  • with_vat (bool)

Return type:

float

Reseller

class loopiase.Reseller(loopia)

Reseller-only API methods.

Accessed via Loopia.reseller:

client = Loopia("reseller@loopiaapi", "password")
customers = client.reseller.get_customers()
Parameters:

loopia (Loopia)

get_customers()

List all sub-customers.

Example:

for customer in client.reseller.get_customers():
    print(customer.customer_number, customer.name)
Return type:

list[Customer]

get_order_status(order_reference, *, customer_number=None)

Check the status of an order created by create_new_account().

Possible statuses: DELETED, PENDING, PROCESSED.

Parameters:
  • order_reference (str)

  • customer_number (str | None)

Return type:

OrderStatus

create_new_account(domain, owner_contact, *, billing_contact_reseller=False, tech_contact_reseller=False, buy_domain=False, domain_configuration='NO_CONFIG', account_type='LOOPIADOMAIN', end_user_has_accepted_terms=True)

Create a new Loopia customer account.

Example:

from loopia import Contact

owner = Contact(
    firstname="Jane",
    lastname="Doe",
    email="jane@example.com",
    street="Main St 1",
    zip="12345",
    city="Stockholm",
    country_iso2="se",
)
result = client.reseller.create_new_account(
    "newcustomer.com",
    owner,
    buy_domain=True,
    domain_configuration="PARKING",
    account_type="LOOPIADOMAIN",
)
print(result.status, result.order_reference)
Parameters:
  • domain (str)

  • owner_contact (Contact)

  • billing_contact_reseller (bool)

  • tech_contact_reseller (bool)

  • buy_domain (bool)

  • domain_configuration (str)

  • account_type (str)

  • end_user_has_accepted_terms (bool)

Return type:

CreateAccountStatus

transfer_credits_by_currency(customer_id, amount, currency)

Transfer LoopiaPREPAID credits to a sub-customer.

Example:

client.reseller.transfer_credits_by_currency("C12345", 100.0, "SEK")
Parameters:
  • customer_id (str)

  • amount (float)

  • currency (str)

Return type:

str