Package: anssdk
PY-ANS-SDKA python sdk to resolve .algo names and perform name operations on ANS .algo names.DocumentationInstall Packagepippip3 install anssdkImportfrom anssdk.ans import ANSSetupalgod_client = "" # set up your algodV2 client
algod_indexer = "" # set up your algod indexer

#indexer is not required if the intention is to only resolve .algo names, but it is required to view the names owned by an algorand wallet address
#indexer and client must point to mainnet

sdk = ANS(algod_client, algod_indexer)Resolve .algo nameResolve .algo name to get the address of the owner. The owner of the account is authorized to manage the domain including setting properties and transfername = "ans.algo"

owner = sdk.name(name).get_owner()
print(owner)Get value propertyThe value property is set by the owner to return a different address when resolving the domain names.name = "ans.algo"

value_property = sdk.name(name).get_value()
print(value_property)Get content propertyThe content property is set by the user to host a website on web3 infrastructure. This is expected to be either a Skylink content ID or an IPFS content IDname = "ans.algo"

content = sdk.name(name).get_content()
print(content)Get text recordReturn text record (socials, avatar etc) set by the owner.name = "ans.algo"
key = "discord"
record = sdk.name(name).get_text(key)
print(record)Get domain informationReturn the entire domain information for the given domains.name = "ans.algo"
information = sdk.name(name).get_all_information()
print(information)Register a new namePrepare name registration transactionsname_to_register = "" #.algo name to register
address = "" # owner's algorand wallet address
period = 0 # duration of registration

try:

    name_registration_txns = sdk.name(name_to_register).register(address, period)

    # Returns a tuple of size two
    # name_registration_txns[0] includes the array of transactions
    # name_registration_txns[1] has the logic sig

    if(len(name_registration_txns[0]) == 2):

        # Lsig account previous opted in (name expired)
        # Sign both transactions
        # Send all to network

    elif(len(name_registration_txns[0]) == 4):

        # name_registration_txns[2] must be signed by the sdk
        # Sign name_registration_txns index 0,1,3
        # Submit transactions as a group

        signed_group_txns = []

        txns = [
            signed_group_txns[0],
            signed_group_txns[1],
            signed_group_txns[2], # must be signed by the sdk
            signed_group_txns[3]
        ]

        # send to network

except:
    passUpdate Name (Set name properties)This method returns transactions to set the social media handles of a domain nametry:

    name = "" #.algo name
    address = "" # owner's algorand address

    edited_handles = {
        'discord': '',
        'github': ''
    }

    update_name_property_txns = sdk.name(name).update(address, edited_handles)

    # Returns an array of transactions
    # Sign each and send to network

except:
    passRenew NameRetrieve transactions to renew a name. The ANS registry currently supports renewal only by the owner hence the transactions will fail if the input address is not the current owner of the name.try:

    name = "" # .algo name
    owner = "" # owner address
    period = 0 # period for renewal

    name_renewal_txns =  sdk.name(name).renew(owner, period)

    # Returns an array of transactions 
    # Sign each and send to network

except:
    passInitiate transferThis method returns a transaction to initiate name transfer. The owner is required to set the price for transfer and the recipient's algorand account address.try:

    name = "" # .algo name to initiate transfer
    owner = "" # current owner
    new_owner = "" # new owner's address
    price = 0 # price at which the seller is willing to sell the name

    name_transfer_transaction = sdk.name(name).init_transfer( owner, new_owner, price)

    # Returns a transaction to be signed by `owner` 
    # Sign and send to network

except:
    passAccept transferRetrieve the transactions to complete the transfer by providing the current owner's address, the transfer recipient's address, and the price set by the ownertry:

    name = "" # .algo name to accept transfer
    owner = "" # current owner
    new_owner = "" # new owner's address
    price = 0 # price set in the previous transaction

    accept_name_transfer_txns = sdk.name(name).accept_transfer( new_owner, owner, price)

    # Returns an array of transactions to be signed by `newOwner`
    # Sign each and send to network

except:
    passGet domains owned by an addressReturns domains owned by an algorand addressaddress="" # provide an algorand address here
socials=True # return socials along with domain information
metadata=True # return metadata along with domain information
limit=1 #limit the number of domains to retrieve

domains = sdk.address(address).get_names(socials, metadata, limit)
print(domains)Get default domainIf configured, this method returns the default domain set by an address. If not configured, this method returns the most recently purchased domain by an addressaddress="" # provide an algorand address here

default_domain = sdk.address(address).get_default_domain()
print(default_domain)