class NamesiloClient::API
Public Class Methods
Class constructor
# File lib/namesilo_client.rb, line 13 def initialize(apikey) @apikey = apikey @host = 'https://www.namesilo.com/api/' end
Public Instance Methods
addAccountFunds: increase NameSilo account funds balance Parameters
amount: the amount in US Dollars payment_id: The ID of the verified credit card
# File lib/namesilo_client.rb, line 570 def add_account_funds(amount,payment_id) params={'amount':amount,'payment_id':payment_id} get_request('addAccountFunds?'+get_url_parameters(params)).body end
addAutoRenewal: Set a domain to be auto-renewed.
# File lib/namesilo_client.rb, line 479 def add_auto_renewal(domain) params={'domain':domain} get_request('addAutoRenewal?'+get_url_parameters(params)).body end
add a contact information params is a JSON string required fields:
fn: First Name ln: Last Name ad: Mailing Address cy: Mailing City st: Mailing State/Province/Territory If country is US or CA, you must use the correct abbreviation zp: Mailing Zip/Postal Code ct: Mailing Country Country must use the correct abbreviation em: Email Address ph: Phone Number
Optional Fields
nn: Nickname (24) cp: Company (64) ad2: Mailing Address 2 (128) fx: Fax (32) US Fields: usnc: .US Nexus Category (3) (must use correct abbreviation) usap: .US Application Purpose (2) (must use correct abbreviation) CA Optional Fields calf: CIRA Legal Form (correct abbreviations) caln: CIRA Language (correct abbreviations) caag: CIRA Agreement Version (correct abbreviations) cawd: CIRA WHOIS Display
# File lib/namesilo_client.rb, line 77 def add_contact(params) get_request('contactAdd?'+get_url_parameters(params)).body end
Add a DNS record Parameters:
domain: The domain being updated rrtype: DNS record type, e.g. "A", "AAAA", "CNAME", "MX" and "TXT" rrhost: hostname for the new record rrvalue: The value for the resource record rrdistance: Only used for MX (default is 10 if not provided) rrttl: The TTL for the new record (default is 7207 if not provided)
# File lib/namesilo_client.rb, line 152 def add_dns_record(params) get_request('dnsAddRecord?'+get_url_parameters(params)).body end
dnsSecAddRecord Parameters
domain digest: The digest keyTag: The key tag digestType: The digest type ( accepted values: https://www.namesilo.com/api_reference.php#dnsSecAddRecord ) alg: see: https://www.namesilo.com/api_reference.php#dnsSecAddRecord
# File lib/namesilo_client.rb, line 400 def add_dns_sec_record(params) get_request('dnsSecAddRecord?'+get_url_parameters(params)).body end
portfolioAdd Parameters:
portfolio: The encoded name of the portfolio to add
# File lib/namesilo_client.rb, line 413 def add_portfolio(portfolio) params={'portfolio':portfolio} get_request('portfolioAdd?'+get_url_parameters(params)).body end
addPrivacy: Add WHOIS Privacy to a domain Parameters:
domain
# File lib/namesilo_client.rb, line 465 def add_privacy(domain) params={'domain':domain} get_request('addPrivacy?'+get_url_parameters(params)).body end
addRegisteredNameServer: add a registered name server Parameters:
new_host: the host name ip1(required): IP Address for new name server ip2-ip13(optional)
# File lib/namesilo_client.rb, line 440 def add_registered_name_server(params) get_request('addRegisteredNameServer?'+get_url_parameters(params)).body end
portfolioDomainAssociate Parameters:
domains portfolio
# File lib/namesilo_client.rb, line 430 def associate_domain_portfolio(portfolio,domains) params={'portfolio':portfolio,'domains':domains} get_request('portfolioDomainAssociate?'+get_url_parameters(params)).body end
changeNameServers Parameters
domain ns1-ns13: must provide between 2 and 13 name servers
# File lib/namesilo_client.rb, line 381 def change_name_servers(params) get_request('changeNameServers?'+get_url_parameters(params)).body end
checkRegisterAvailability Parameter: register domain names in JSON, seperated by comma
e.g. {'domains':'namesilo.com,namesilo.net,namesilo.org'}
returns XML with available, unavailable, and invalid domains xpath: /namesilo/reply
# File lib/namesilo_client.rb, line 189 def check_register_availability(domains) get_request('checkRegisterAvailability?'+get_url_parameters({'domains':domains})).body end
checkTransferAvailability Parameters
domains: A comma-delimited list of domains
# File lib/namesilo_client.rb, line 360 def check_transfer_availability(domains) params={'domains':domains} get_request('checkTransferAvailability?'+get_url_parameters(params)).body end
checkTransferStatus Parameter: domain name returns XML containing domain transfer status xpath: /namesilo/reply
# File lib/namesilo_client.rb, line 180 def check_transfer_status(domain) get_request('checkTransferStatus?'+get_url_parameters({'domain':domain})).body end
contactDomainAssociate Parameters
domains (required) registrant(optional): registrant's contact id administrative(optional): admin's contact id billing(optional): billing contact id technical(optional): technical role contact id
# File lib/namesilo_client.rb, line 373 def contact_domain_associate(params) get_request('contactDomainAssociate?'+get_url_parameters(params)).body end
dnsSecDeleteRecord Parameters: as same as dnsSecAddRecord
# File lib/namesilo_client.rb, line 406 def del_dns_sec_record(params) get_request('dnsSecDeleteRecord?'+get_url_parameters(params)).body end
contactDelete
# File lib/namesilo_client.rb, line 88 def delete_contact(contact_id) params={'contact_id':contact_id} get_request('contactDelete?'+get_url_parameters(params)).body end
Delete DNS record Parameters:
domain rrid: The unique ID of the resource record
# File lib/namesilo_client.rb, line 172 def delete_dns_record(params) get_request('dnsDeleteRecord?'+get_url_parameters(params)).body end
deleteEmailForward: delete a email forward Parameters
domain email
# File lib/namesilo_client.rb, line 553 def delete_forward_email(domain,email) params={'domain':domain, 'email':email} get_request('deleteEmailForward?'+get_url_parameters(params)).body end
domainForwardSubDomainDelete: delete a subdomain forward Parameters
domain subdomain
# File lib/namesilo_client.rb, line 516 def delete_forward_sub_domain(domain, subdomain) params={'domain':domain, 'subdomain':subdomain} get_request('domainForwardSubDomainDelete?'+get_url_parameters(params)).body end
portfolioDelete Parameters:
portfolio: The encoded name of the portfolio to add
# File lib/namesilo_client.rb, line 421 def delete_portfolio(portfolio) params={'portfolio':portfolio} get_request('portfolioDelete?'+get_url_parameters(params)).body end
deleteRegisteredNameServer Parameters:
current_host: current host name
# File lib/namesilo_client.rb, line 457 def delete_registered_name_server(hostname) params={'hostname':hostname} get_request('deleteRegisteredNameServer?'+get_url_parameters(params)).body end
emailVerification: sned an email verification message Parameters
email
# File lib/namesilo_client.rb, line 561 def email_verification(email) params={'email':email} get_request('emailVerification?'+get_url_parameters(params)).body end
domainForward Required parameters:
domain protocol: http or https address: the web site address to forward to method: "301", "302" or "cloaked"
Optional parameters:
meta_title: The META title for cloaked forward meta_description meta_keywords: The META keywords for cloaked forward
# File lib/namesilo_client.rb, line 501 def forward_domain(params) get_request('domainForward?'+get_url_parameters(params)).body end
configureEmailForward: create a new email forward or modify an existing email forward Required parameters
domain email forward1: the first email address to foward emails
Optional parameters
forward2-5
# File lib/namesilo_client.rb, line 545 def forward_email(params) get_request('configureEmailForward?'+get_url_parameters(params)).body end
domainForwardSubDomain Parameters: as same as forward_domain
, plus:
sub_domain
# File lib/namesilo_client.rb, line 508 def forward_sub_domain(params) get_request('domainForwardSubDomain?'+get_url_parameters(params)).body end
getAccountBalance returns current account funds balance. xpath: /namesilo/reply
# File lib/namesilo_client.rb, line 264 def get_account_balance() get_request('getAccountBalance?'+get_url_parameters({})).body end
Establish connection
# File lib/namesilo_client.rb, line 19 def get_connection() conn = Faraday.new(:url => @host) do |c| c.use Faraday::Request::UrlEncoded c.use Faraday::Adapter::NetHttp end end
Return namesilo contact information By default, it returns all contact informaton Optional parameter: contact_id e.g. get_contact_list
(params={contact_id:'11111111'})
# File lib/namesilo_client.rb, line 46 def get_contact_list(params={}) get_request('contactList?'+get_url_parameters(params)).body end
Default parameters for Namesilio REST APIs
# File lib/namesilo_client.rb, line 27 def get_default_parameters() {"version":"1","type":"xml","key":@apikey} end
Get domain info Parameter: domain name returns XML containing all domain info xpath: /namesilo/reply
# File lib/namesilo_client.rb, line 114 def get_domain_info(domain) get_request('getDomainInfo?'+get_url_parameters({'domain':domain})).body end
Get a list of all active portfolios within your account. returns XML containing all portfolios xpath: /namesilo/reply/portfolios
# File lib/namesilo_client.rb, line 202 def get_portfolio_list() get_request('portfolioList?'+get_url_parameters({})).body end
getPrices returns price list xpath: /namesilo/reply
# File lib/namesilo_client.rb, line 271 def get_prices() get_request('getPrices?'+get_url_parameters({})).body end
registrantVerificationStatus Shows the verification status for any Registrant email addresses xpath: /namesilo/reply/email
# File lib/namesilo_client.rb, line 257 def get_registrant_verification_status() get_request('registrantVerificationStatus?'+get_url_parameters({})).body end
# File lib/namesilo_client.rb, line 31 def get_request(endpoint) get_connection().get endpoint end
Construct URL parameters, combing with default parameters
# File lib/namesilo_client.rb, line 36 def get_url_parameters(params) uri = Addressable::URI.new uri.query_values = params.merge(get_default_parameters()) uri.query end
List DNS records Parameter: domain name returns XML containing all DNS records xpath: /namesilo/reply/resource_record
# File lib/namesilo_client.rb, line 122 def list_dns_records(domain) get_request('dnsListRecords?'+get_url_parameters({'domain':domain})).body end
List DNS records Returns an array containing DNS record object
# File lib/namesilo_client.rb, line 128 def list_dns_records_array(domain) dns_records = [] doc = Nokogiri::XML(list_dns_records(domain)) doc.xpath('/namesilo/reply/resource_record').each do |r| record = DnsRecord.new record.recordid = r.xpath('record_id').text() record.host = r.xpath('host').text() record.type = r.xpath('type').text() record.value = r.xpath('value').text() record.ttl = r.xpath('ttl').text() record.distance = r.xpath('distance').text() dns_records << record end dns_records end
dnsSecListRecords Parameters
domain
# File lib/namesilo_client.rb, line 388 def list_dns_sec_records(domain) params={'domain':domain} get_request('dnsSecListRecords?'+get_url_parameters(params)).body end
List all domains Returns XML xpath: /namesilo/reply/domains/domain
# File lib/namesilo_client.rb, line 96 def list_domains() get_request('listDomains?'+get_url_parameters({})).body end
list all domains in Array
# File lib/namesilo_client.rb, line 101 def list_domains_array() domains = [] doc = Nokogiri::XML(list_domains()) doc.xpath('/namesilo/reply/domains/domain').each do |domain| domains << domain end domains end
listEmailForwards returns all email forwards xpath: /namesilo/reply/addresses
# File lib/namesilo_client.rb, line 233 def list_email_forwards(domain) get_request('listEmailForwards?'+get_url_parameters({'domain':domain})).body end
return email forwards array
# File lib/namesilo_client.rb, line 238 def list_email_forwards_array(domain) email_forwards = [] doc = Nokogiri::XML(list_email_forwards(domain)) doc.xpath('/namesilo/reply/addresses').each do |a| ef = EmailForward.new ef.email = a.xpath('email').text() fts = [] a.xpath('forwards_to').each do |ft| fts << ft.text() end ef.forwards_to = fts email_forwards << ef end email_forwards end
listRegisteredNameServers returns XML containing all name servers xpath: /namesilo/reply/hosts
# File lib/namesilo_client.rb, line 209 def list_name_servers(domain) get_request('listRegisteredNameServers?'+get_url_parameters({'domain':domain})).body end
# File lib/namesilo_client.rb, line 214 def list_name_servers_array(domain) name_servers = [] doc = Nokogiri::XML(list_name_servers(domain)) doc.xpath('/namesilo/reply/hosts').each do |r| h = Host.new h.host = r.xpath('host').text() ips = [] r.xpath('ip').each do |ip| ips << ip.text() end h.ips = ips name_servers << h end name_servers end
listOrders Returns Complete Account Order History xpath: /namesilo/reply/order
# File lib/namesilo_client.rb, line 278 def list_orders() get_request('listOrders?'+get_url_parameters({})).body end
domainLock: set a domain to be locked Parameters
domain
# File lib/namesilo_client.rb, line 524 def lock_domain(domain) params={'domain':domain} get_request('domainLock?'+get_url_parameters(params)).body end
marketplaceActiveSalesOverview: a list for all active Marketplace sales in your account.
# File lib/namesilo_client.rb, line 576 def marketplace_active_sales_overview() params={} get_request('marketplaceActiveSalesOverview?'+get_url_parameters(params)).body end
marketplaceAddOrModifySale Parameters: see www.namesilo.com/api_reference.php#marketplaceAddOrModifySale
# File lib/namesilo_client.rb, line 583 def marketplace_add_sale(params) get_request('marketplaceAddOrModifySale?'+get_url_parameters(params)).body end
marketplaceLandingPageUpdate required parameters
domain
optional parameters: see www.namesilo.com/api_reference.php#marketplaceLandingPageUpdate
# File lib/namesilo_client.rb, line 592 def marketplace_landing_page_update(params) get_request('marketplaceLandingPageUpdate?'+get_url_parameters(params)).body end
modifyRegisteredNameServer Parameters:
current_host: current host name new_host: the new host name ip1 ip2-ip13
# File lib/namesilo_client.rb, line 450 def modify_registered_name_server(params) get_request('modifyRegisteredNameServer?'+get_url_parameters(params)).body end
orderDetails returns details for provided order number xpath: /namesilo/reply
# File lib/namesilo_client.rb, line 285 def order_details(order_number) get_request('orderDetails?'+get_url_parameters({'order_number':order_number})).body end
registerDomain Parameters
domain(required): The domain to renew years(required): The number of years to renew the domain payment_id(optional) coupon(optional) private(optional): if the free WHOIS privacy service will be used or not auto_renew(optional) portfolio(optional): the name of the portfolio to link the registered domain with ns1-13(optional): up to 13 name servers to use for the domain registration contact info(optional): see https://www.namesilo.com/api_reference.php#registerDomain
# File lib/namesilo_client.rb, line 312 def register_domain(params) get_request('registerDomain?'+get_url_parameters(params)).body end
removeAutoRenewal: set a domain to not be auto-renewed
# File lib/namesilo_client.rb, line 485 def remove_auto_renewal(domain) params={'domain':domain} get_request('removeAutoRenewal?'+get_url_parameters(params)).body end
removePrivacy Parameters:
domain
# File lib/namesilo_client.rb, line 473 def remove_privacy(domain) params={'domain':domain} get_request('removePrivacy?'+get_url_parameters(params)).body end
renewDomain Parameters (format should be in JSON, e.g. {'domain':'yourdomain.com','years':'1'}):
domain(required): The domain to renew years(required): The number of years to renew the domain payment_id(optional): the id of verified payment method, if not specified, your account balance will be used coupon(optional): the coupon code used in this transaction
# File lib/namesilo_client.rb, line 296 def renew_domain(params) get_request('renewDomain?'+get_url_parameters(params)).body end
retrieveAuthCode Have the EPP transfer code for the domain emailed to the administrative contact.
# File lib/namesilo_client.rb, line 195 def retrieve_auth_code(domain) get_request('retrieveAuthCode?'+get_url_parameters({'domain':domain})).body end
transferDomain Parameters
domain(required) payment_id(optional) auth(optional): transfer authorization code private(optional): if you want the domain to utilize our free WHOIS privacy service auto_renew(optional) portfolio(optional) coupon(optional) Passing Contact Information(optional): see https://www.namesilo.com/api_reference.php#transferDomain Passing Contact ID(optional): see https://www.namesilo.com/api_reference.php#transferDomain
# File lib/namesilo_client.rb, line 328 def transfer_domain(params) get_request('transferDomain?'+get_url_parameters(params)).body end
transferUpdateChangeEPPCode Parameters
domain auth: The EPP code to use
# File lib/namesilo_client.rb, line 336 def transfer_update_change_epp_code(domain,epp_code) params={'domain':domain,'auth':epp_code} get_request('transferUpdateChangeEPPCode?'+get_url_parameters(params)).body end
transferUpdateResendAdminEmail Parameters
domain
# File lib/namesilo_client.rb, line 344 def transfer_update_resend_admin_email(domain) params={'domain':domain} get_request('transferUpdateResendAdminEmail?'+get_url_parameters(params)).body end
transferUpdateResubmitToRegistry Parameters
domain
# File lib/namesilo_client.rb, line 352 def transfer_update_resubmit_to_registry(domain) params={'domain':domain} get_request('transferUpdateResubmitToRegistry?'+get_url_parameters(params)).body end
domainUnlock Parameters
domain
# File lib/namesilo_client.rb, line 532 def unlock_domain(domain) params={'domain':domain} get_request('domainUnlock?'+get_url_parameters(params)).body end
contactUpdate Parameters: see add_contact
# File lib/namesilo_client.rb, line 83 def update_contact(params) get_request('contactUpdate?'+get_url_parameters(params)).body end
Update DNS record Parameters:
domain rrid: The unique ID of the resource record. rrhost: The hostname rrvalue: The value for the resource record rrdistance: Only used for MX rrttl: The TTL for this record (default is 7207 if not provided)
# File lib/namesilo_client.rb, line 164 def update_dns_record(params) get_request('dnsUpdateRecord?'+get_url_parameters(params)).body end