Package: python-transip
Python TransIPpython-transipis an Python wrapper for theTransIP REST API V6.IntroductionInstallationDocumentationAuthenticationGeneralProductsTheProductclassTheProductElementclassList all productsList specifications for productAvailability ZonesTheAvailabilityZoneclassList availability zonesAPI TestAccountInvoicesTheInvoiceclassTheInvoiceItemclassList all invoicesList a single invoiceList invoice items by invoice numberRetrieve an invoice as PDF fileSSH KeysTheSshKeyclassList all SSH keysGet SSH key by idAdd a new SSH keyUpdate an SSH keyDelete an SSH keyDomainDomainsTheDomainclassList all domainsRetrieve an existing domainDNSTheDnsEntryclassList all DNS entries for a domainAdd a new single DNS entry to a domainUpdate single DNS entryUpdate all DNS entries for a domainRemove a DNS entry from a domainNameserversTheNameserverclassList nameservers for a domainUpdate nameservers for a domainVPSHA-IPColocationColocationsTheColocationclassList all colocationsGet colocationIntroductionWelcome to the Python TransIP documentation.REST API V6python-transipimplements the new TransIP REST API to manage all products in a RESTful way, this means that for most products you can make simple create, update and delete calls.The wrapper tries to stay close to the naming convention of the officialAPI documentation.SOAP V5 API (deprecated)Users are strongly advised to use the new REST API because the SOAP API has been deprecated. If you still depend on functionality that has not yet been implemented inpython-transipconsider raising afeature requestand usingtransip-api (deprecated)in the meanwhile.Installationpython-transipis available on PyPI:$python-mpipinstallpython-transippython-transipofficially supports Python 3.6+.DocumentationThe full API Reference and User Guide is available onRead the Docs.AuthenticationIn order to manage TransIP products viapython-transipyou will need to be authenticated. TheREST API V6requires an access token that makes use of theJSON Web Tokenstandard.To get an access token, you should first generate a key pair using thecontrol panel. You can than pass the private key to thepython-transipclient to allow the client to generate a new access token, e.g.:importtransip# You can initialize a TransIP client using a private key directly.PRIVATE_KEY='''-----BEGIN PRIVATE KEY-----...'''client=transip.TransIP(login='demouser',private_key=PRIVATE_KEY)# You can also initialize a TransIP client by telling it where to find the# private key file on the system.client=transip.TransIP(login='demouser',private_key_file='/path/to/private.key')Alternatively you can also authenticate by providing an access token. This is especially useful when testing the API with thedemo token, e.g.:importtransipfromtransip.v6importDEMO_TOKEN# You can initialize a TransIP client using an access token directly.client=transip.TransIP(access_token=DEMO_TOKEN)GeneralThegeneral TransIP APIresources allow you to manage products, availability zones and call the API test resource.ProductsManage available TransIP products and product specifications.TheProductclassWhen listing all products available on TransIP, a list oftransip.v6.objects.Productobjects is returned.classProductTheProductclass makes the following attributes available:name: The name of the product.description: The product description.price: The price in cents.recurringPrice: The recurring price for the product in cents.elements: The service to list detailed information on the product elements.TheProductElementclassWhen listing all product elements of atransip.v6.objects.Productobject, a list oftransip.v6.objects.ProductElementobjects is returned.classProductElementTheProductElementclass makes the following attributes available:name: The name of the product element.description: The product element description.amount: The amount.List all productsRetrieve al list of products with, there name, description and price.importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# List all available TransIP products.products=client.products.list()# Show product information on the screen.forproductinproducts:print((f"Product{product.name}({product.description}) costs "f"{product.price}(cents), after which it costs "f"{product.recurringPrice}(cents)"))List specifications for productGet the specification for a product. This will list all the different elements for a product with the amount that it comes with, e.g. a avps-bladevps-x4has 2 CPU-core elements.importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Show product specification information on the screen for all available# TransIP products.forproductinclient.products.list():print(f"Product{product.name}({product.description}):")elements=product.elements.list()forelementinelements:print(f"- Has{element.amount}{element.name}:{element.description}")Availability ZonesManage TransIP availability zones.TheAvailabilityZoneclassWhen listing all the available availability zones on TransIP, a list oftransip.v6.objects.AvailabilityZoneobjects is returned.classAvailabilityZoneTheAvailabilityZoneclass makes the following attributes available:name: The name of the availability zone.country: The 2 letter code for the country the AvailabilityZone is in.isDefault: If true this is the default zone new VPSes and clones are created inList availability zonesRetrieve the available availability zones:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# List all available availability zones.zones=client.availability_zones.list()# Show availability zone information on the screen.forzoneinzones:print((f"Availability zone{zone.name}in{zone.country}"f"(default:{zone.isDefault})"))API TestA simple test resource to make sure everything is working.importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Check if everything is working by calling the API test resource.ifclient.api_test.test():print("Everthing is working!")AccountTheaccount TransIP APIresources allow you to manage invoices and SSH keys.InvoicesManage invoices attached to your TransIP account.TheInvoiceclassWhen listing all invoices attached to your TransIP account, a list oftransip.v6.objects.Invoiceobjects is returned.classInvoiceTheInvoiceclass makes the following attributes available:invoiceNumber: The invoice number.creationDate: The invoice creation date.payDate: The invoice paid date.dueDate: The invoice deadline.invoiceStatus: The invoice status.currency: The currency used for this invoice.totalAmount: The invoice total (displayed in cents).totalAmountInclVat: The invoice total including VAT (displayed in cents).items: The service to list detailed information on the individual invoice items.TheInvoiceItemclassWhen listing all invoices items attached to atransip.v6.objects.Invoiceobject, a list oftransip.v6.objects.InvoiceItemobjects is returned.classInvoiceItemTheInvoiceItemclass makes the following attributes available:product: The product name.description: The product description.isRecurring: Whether or not the payment is recurring.date: The date when the order line item was up for invoicing.quantity: The quantity of the invoice item.price: The price excluding VAT (displayed in cents).priceInclVat: The price including VAT (displayed in cents).vat: The amount of VAT charged.vatPercentage: The percentage used to calculate the VAT.discounts: The dictionary containing the applied discounts.description: The applied discount description.amount: The discounted amount (in cents).The class has the following methods:pdf(file_path)stores the invoice as a PDF file on a location provided by thefile_pathkeyword argument. When thefile_pathis a directory, the PDF file will be saved using the invoice number as its basename.List all invoicesRetrieve all invoices attached to your TransIP account by callingtransip.TransIP.invoices.list(). This will return a list oftransip.v6.objects.Invoiceobjects.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# List all invoices attached to your TransIP account.invoices=client.invoices.list()# Show invoice information on the screen.forinvoiceininvoices:print(f"Invoice{invoice.invoiceNumber}was paid on{invoice.payDate}")Note:when using the demo access token, the API currently doesn't list any invoices.List a single invoiceRetrieve a single invoice attached to your TransIP account by its invoice number by callingtransip.TransIP.invoices.get(id). This will return atransip.v6.objects.Invoiceobject.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a single invoice by its invoice number.invoice=client.invoices.get('F0000.1911.0000.0004')# Show invoice information on the screen.print(f"Invoice{invoice.invoiceNumber}was paid on{invoice.payDate}")Note:when using the demo access token, the API currently doesn't list any invoices.List invoice items by invoice numberRetrieve the invoice items of a single invoice attached to your TransIP account by its invoice number by callingitems.list()on atransip.v6.objects.Invoiceobject. This will return a list oftransip.v6.objects.InvoiceItemobjects.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a single invoice by its invoice number.invoice=client.invoices.get('F0000.1911.0000.0004')# Retrieve all items of a single invoice.items=invoice.items.list()# Show invoice information on the screen.foriteminitems:print(f"Product{item.product}({item.description})")Note:when using the demo access token, the API currently doesn't list any invoices.Retrieve an invoice as PDF fileAny of the invoices can be saved as a PDF file by callingpdf(file_path)on atransip.v6.objects.Invoiceobject:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a single invoice by its invoice number.invoice=client.invoices.get('F0000.1911.0000.0004')# Save the invoice as a PDF file.invoice.pdf('/path/to/invoices/')Note:when using the demo access token, the API currently doesn't list any invoices.SSH KeysTheSshKeyclassWhen listing all SSH keys attached to your TransIP account, a list oftransip.v6.objects.SshKeyobjects is returned.classSshKeyTheSshKeyclass makes the following attributes available:id: The SSH key identifier.key: The SSH key.description: The SSH key description (max 255 chars).creationDate: The date when this SSH key was added (timezone: Europe/Amsterdam)fingerprint: MD5 fingerprint of SSH key.The class has the following methods:delete()will delete the SSH key in your TransIP account.update()will send the updated attributes to the TransIP API.List all SSH keysRetrieve all SSH keys attached to your TransIP account by callingtransip.TransIP.ssh_keys.list(). This will return a list oftransip.v6.objects.SshKeyobjects.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# List all SSH keys attached to your TransIP account.ssh_keys=client.ssh_keys.list()# Show SSH key information on the screen.forssh_keyinssh_keys:print(f"SSH key{ssh_key.id}has fingerprint{ssh_key.fingerprint}")Note:when using the demo access token, the API currently doesn't list any SSH keys.Get SSH key by idRetrieve a single SSH key attached to your TransIP account by its ID by callingtransip.TransIP.ssh_key.get(id). This will return atransip.v6.objects.SshKeyobject.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a SSH key by its ID (provided by TransIP).invoice=client.ssh_keys.get(123)# Show SSH key information on the screen.print(f"SSH key{ssh_key.id}has fingerprint{ssh_key.fingerprint}")Note:when using the demo access token, the API currently doesn't list any SSH keys.Add a new SSH keyAdd a new SSH key to your TransIP account by callingtransip.TransIP.ssh_key.create(data). Thedatakeyword argument requires a dictionary with thesshKeyanddescriptionattributes.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Data used to create a new SSH key.key_data={"sshKey":"ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQDf2pxWX/yhUBDyk2LPhvRtI0LnVO8PyR5Zt6AHrnhtLGqK+8YG9EMlWbCCWrASR+Q1hFQG example","description":"Jim key"}# Add the new SSH key to your TransIP account.client.ssh_keys.create(key_data)Note:when using the demo access token, the API currently doesn't list any SSH keys.Update an SSH keyUpdate an existing SSH key in your TransIP account by callingtransip.TransIP.ssh_key.update(id,data). Theidkeyword argument is the ID of the SSH key provided by TransIP anddatakeyword argument requires a dictionary with thesshKeyanddescriptionattributes.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Dictionary containing the new description of the SSH keykey_data={"description":"Jim key"}# Update SSH key (ID: 123) with the new description.client.ssh_keys.update(123,key_data)Thetransip.v6.objects.SshKeyclass also provides aupdate()method to update aSshKeyobject from an instance after changing any of the update-able attributes.Note:when using the demo access token, the API currently doesn't list any SSH keys.Delete an SSH keyDelete an existing SSH key in your TransIP account by callingtransip.TransIP.ssh_key.delete(id). Theidkeyword argument is the ID of the SSH key provided by TransIP.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Delete SSH key with ID 123.client.ssh_keys.delete(123)Thetransip.v6.objects.SshKeyclass also provides adelete()method to delete aSshKeyobject from an instance.Note:when using the demo access token, the API currently doesn't list any SSH keys.DomainThedomains TransIP APIresources allow you to manage domains, branding, contacts, DNS, DNSSEC, nameservers, actions, SSL, WHOIS, availability  and call the tlds resource.The documentation for managingdomainsand related resources has not yet completely been documented. Feel free to file anissuefor adding the missing section(s) in the documentation.DomainsManage domains.TheDomainclassWhen listing all domains in your TransIP account, a list oftransip.v6.objects.Domainobjects is returned.classDomainTheDomainclass makes the following attributes available:name: The name, including the tld of this domain.authCode: The authcode for this domain as generated by the registry.isTransferLocked: If this domain supports transfer locking, this flag is True when the domains ability to transfer is locked at the registry.registrationDate: The registration date of the domain, in YYYY-mm-dd format.renewalDate: The next renewal date of the domain, in YYYY-mm-dd format.isWhitelabel: If this domain is added to your whitelabel.cancellationDate: Cancellation data, in YYYY-mm-dd h:i:s format, None if the domain is active.cancellationStatus: Cancellation status, None if the domain is active, ‘cancelled’ when the domain is cancelled.isDnsOnly: Whether this domain is DNS only.tags: The custom tags added to this domain.contacts: The service to manage the domain contacts.dns: The service to manage the DNS-records of the domain.nameservers: The service to manage the nameservers of the domain.List all domainsRetrieve all domains registered in your TransIP account by callingtransip.TransIP.domains.list(). This will return a list oftransip.v6.objects.Domainobjects.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# List all domains.domains=client.domains.list()# Show domain information on the screen.fordomainindomains:print(f"Domain{domain.name}was registered at{domain.registrationDate}")Retrieve an existing domainRetrieve a single domain registered ion your TransIP account by its ID by callingtransip.TransIP.domains.get(name). This will return atransip.v6.objects.Domainobject.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a domain by its namedomain=client.domains.get('transipdemonstratie.nl')# Show domain information on the screen.print(f"Domain{domain.name}was registered at{domain.registrationDate}")DNSManage DNS records of a domain. Any changes made here will be pushed to the TransIP nameservers.TheDnsEntryclassWhen listing all DNS-records of atransip.v6.objects.Domainobject, a list oftransip.v6.objects.DnsEntryobjects is returned.classDnsEntryTheDnsEntryclass makes the following attributes available:name: The name of the dns entry, for example ‘@’ or ‘www’expire: The expiration period of the dns entry, in seconds. For example 86400 for a day of expiration.type: The type of dns entry. Possbible types are ‘A’, ‘AAAA’, ‘CNAME’, ‘MX’, ‘NS’, ‘TXT’, ‘SRV’, ‘SSHFP’ and ‘TLSA’.content: The content of of the dns entry, for example ‘10 mail’, ‘127.0.0.1’ or ‘www’.The class has the following methods:delete()will delete the DNS-record from the domain.update()will send the updated attributes to the TransIP API. This can only be used when updating thecontentattribute of a DnsEntry and when there aren't any other DNS records with the samename,expireandtypeattributes.List all DNS entries for a domainRetrieve the DNS records of a single domain registered in your TransIP account by callingdns.list()on atransip.v6.objects.Domainobject. This will return a list oftransip.v6.objects.DnsEntryobjects.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a domain by its name.domain=client.domains.get('transipdemonstratie.nl')# Retrieve the DNS records of a single domain.records=domain.dns.list()# Show the DNS record information on the screen.forrecordinrecords:print(f"DNS:{record.name}{record.expire}{record.type}{record.content}")Add a new single DNS entry to a domainAdd an new DNS record to a domain by callingdns.create(data)on atransip.v6.objects.Domainobject. Thedatakeyword argument a dictionary containing thename,expire,typeandcontentattributes.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a domain by its name.domain=client.domains.get('transipdemonstratie.nl')# Dictionary containing the information for a single DNS record.dns_entry_data={"name":"www","expire":86400,"type":"A","content":"127.0.0.1"}# Add the DNS record to the domain.domain.dns.create(dns_entry_data)Update single DNS entryUpdate a single DNS record of a domain by callingdns.update(data)on atransip.v6.objects.Domainobject. Thedatakeyword argument a dictionary containing thename,expire,typeandcontentattributes.This can only be used when updating thecontentattribute of a DNS entry and when there aren't any other DNS records with the samename,expireandtypeattributes.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a domain by its name.domain=client.domains.get('transipdemonstratie.nl')# Dictionary containing the information for a single updated DNS record.dns_entry_data={"name":"www","expire":86400,"type":"A","content":"127.0.0.2"# The update content.}# Update the content of a single DNS record.domain.dns.update(dns_entry_data)Update all DNS entries for a domainUpdate all DNS records of a single domain registered in your TransIP account at once by callingdns.replace()on atransip.v6.objects.Domainobject.Note:This will wipe all existing DNS records with the provided records.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a domain by its name.domain=client.domains.get('transipdemonstratie.nl')# Retrieve the DNS records of a single domain.records=domain.dns.list()forrecordinrecords:# Update the A-record for localhostifrecord.name=='localhost'andrecord.type=='A':record.content='127.0.0.1'# Replace all the records with the updated onesdomain.dns.replace(records)Remove a DNS entry from a domainDelete an existing DNS record from a domain by callingdns.delete(data)on atransip.v6.objects.Domainobject. Thedatakeyword argument a dictionary containing thename,expire,typeandcontentattributes.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a domain by its name.domain=client.domains.get('transipdemonstratie.nl')# Dictionary containing the information for a single DNS record.dns_entry_data={"name":"www","expire":86400,"type":"A","content":"127.0.0.1"}# Delete the DNS record from the domain.domain.dns.delete(dns_entry_data)Thetransip.v6.objects.DnsEntryclass also provides adelete()method to delete aDnsEntryobject from an instance.NameserversManage the nameserver of a domain.TheNameserverclassWhen listing all nameservers of atransip.v6.objects.Domainobject, a list oftransip.v6.objects.Nameserverobjects is returned.classNameserverTheNameserverclass makes the following attributes available:hostname: The hostname of this nameserver.ipv4: The optional ipv4 glue record for this nameserver.ipv6: The optional ipv6 glue record for this nameserverList nameservers for a domainRetrieve the nameserver of a single domain registered in your TransIP account by callingnameserver.list()on atransip.v6.objects.Domainobject. This will return a list oftransip.v6.objects.Nameserverobjects.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a domain by its name.domain=client.domains.get('transipdemonstratie.nl')# Retrieve the nameservers of a single domain.nameservers=domain.nameservers.list()# Show the nameserver information on the screen.fornameserverinnameservers:print(f"Nameserver:{nameserver.hostname}")Update nameservers for a domainUpdate all the nameservers of a single domain registered in your TransIP account at once by callingnameservers.replace()on atransip.v6.objects.Domainobject.Note:This will wipe all nameservers previously configured on the domain.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a domain by its name.domain=client.domains.get('transipdemonstratie.nl')# Retrieve the nameservers of the domain.nameservers=domain.nameservers.list()# Update the ipv4 glue record of the first nameserver.nameserver[0].ipv4='195.135.195.195'# Replace all the records with the updated onesdomain.nameservers.replace(nameservers)VPSThe documentation for managingVPSsand related resources has not yet been documented. Feel free to file anissuefor adding the missing section(s) in the documentation.HA-IPThe documentation for managingHA-IPsand related resources has not yet been documented. Feel free to file anissuefor adding the missing section(s) in the documentation.ColocationThe documentation for managingcolocationsand related resources has not yet been documented. Feel free to file anissuefor adding the missing section(s) in the documentation.ColocationsManage colocations.TheColocationclassWhen listing all colocations in your TransIP account, a list oftransip.v6.objects.Colocationobjects is returned.classColocationTheColocationclass makes the following attributes available:name: The colocation name.ipRanges: The list of IP ranges.List all colocationsRetrieve the colocations registered in your TransIP account by callingtransip.TransIP.colocations.list(). This will return a list oftransip.v6.objects.Colocationobjects.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve the colocations registered in your TransIP account.colocations=client.colocations.list()# Show the colocations information on the screen.forcolocationincolocations:ip_ranges=' '.join(colocation.ipRanges)print(f"Colocation:{colocation.name}has IP ranges:{ip_ranges}")Get colocationRetrieve a single colocation registered in your TransIP account by its ID by callingtransip.TransIP.colocations.get(name). This will return atransip.v6.objects.Colocationobject.For example:importtransip# Initialize a client using the TransIP demo token.client=transip.TransIP(access_token=transip.v6.DEMO_TOKEN)# Retrieve a colocation by its name.colocation=client.colocations.get('example2')# Show colocation information on the screen.ip_ranges=' '.join(colocation.ipRanges)print(f"Colocation:{colocation.name}has IP ranges:{ip_ranges}")ChangelogAll notable changes inpython-transipare documented below.Unreleased0.6.0(2021-11-01)AddedPython 3.10 support (#49).0.5.0(2021-02-10)AddedThe option to replace all existing nameservers of a single domain at once from thetransip.v6.objects.Domain.nameserversservice.The option to list all colocations from thetransip.TransIP.colocationsservice (#24).The option to retrieve a single colocation by name from thetransip.TransIP.colocationsservice (#24).The option to allow the access token to be used from all IP-addresses instead of only the whitelisted ones (#46).0.4.0(2021-01-24)AddedThisCHANGELOG.mdfile to be able to list all notable changes for each version ofpython-transip.Thetransip.TransIP.api_testservice to allow calling the test resource to make sure everything is working.The option to list all invoices attached to your TransIP account from thetransip.TransIP.invoicesservice.The option to save an invoice as PDF file fromtransip.v6.objects.Invoiceobject.The option to list all products available in TransIP from thetransip.TransIP.productsservice.The option to update a single SSH key fromtransip.v6.objects.SshKeyobject.The option to update the content of a single DNS record from thetransip.v6.objects.Domain.dnsservice, as well as from thetransip.v6.objects.DnsEntryobject.The option to replace all existing DNS records of a single domain at once from thetransip.v6.objects.Domain.dnsservice.