1

I try to implement delete method for Record delate-record, but its my first time to use python and this api.

3 Answers3

2

The GoDaddy API doesn't have a delete record method, so this functionality is not exposed in the driver. https://developer.godaddy.com/doc#!/_v1_domains/recordReplace

The driver could offer the 'replace records in zone' method, which would allow you to fetch the current list of records, and then set the new list minus the record you want to remove. But that feature is not implemented and quite risky.

anthony shaw
  • 133
  • 11
2

First, Send a GET request to https://api.godaddy.com/v1/domains/{DOMAIN}/records

Then, Enumerate over all records of API Response (JSON Array) and prepare new data by removing the one that needs to be deleted.

API Response (SAMPLE)

[
    {
        "data": "192.168.1.1",
        "name": "@",
        "ttl": 600,
        "type": "A"
    },
    {
        "data": "ns1.example.com",
        "name": "@",
        "ttl": 3600,
        "type": "NS"
    },
    {
        "data": "@",
        "name": "www",
        "ttl": 3600,
        "type": "CNAME"
    },
    {
        "data": "mail.example.com",
        "name": "@",
        "ttl": 3600,
        "priority": 1,
        "type": "MX"
    }
]

New Data (After deleting record) (SAMPLE)

[
    {
        "data": "192.168.1.1",
        "name": "@",
        "ttl": 600,
        "type": "A"
    },
    {
        "data": "ns1.example.com",
        "name": "@",
        "ttl": 3600,
        "type": "NS"
    },
    {
        "data": "@",
        "name": "www",
        "ttl": 3600,
        "type": "CNAME"
    }
]

Now, Send a PUT request to https://api.godaddy.com/v1/domains/{DOMAIN}/records with new data.

The most important thing is how you identify the records in above array which needs to be deleted. This would not be a difficult task, assuming you have good programming skills.

Krishna
  • 165
  • 1
  • 12
  • You can make the search and replace more selective by putting the record type in the URL path e.g. `https://api.godaddy.com/v1/domains/{DOMAIN}/records/A` – Bruce May 05 '20 at 20:24
1

I managed to worked around it in kind of a hacky - we had bunch of records we wanted to delete, doing it manually seemed weird so I added a Javascript into the Chrome Developer Console, running on an authenticated session from the DNS manage page:

function deleteGoDaddyRecords(recordId) {
        $.ajax({
        url: 'https://dcc.godaddy.com/api/v3/domains/<YOUR-DOMAIN.com>/records?recordId='+recordId,
        type: 'DELETE',
        success: function(result) {
            console.log(result)
        }
    });
}

which let me use the same call the UI is calling when you ask to delete a record.

the only thing you need to provide is the AttributeUid which is not available with the public API, but it is in the front-end API:

https://dcc.godaddy.com/api/v2/domains/runahr.com/records

So I managed to create a script that will generate bunch of

deleteGoDaddyRecords('<RECORD-UUID>');
deleteGoDaddyRecords('<RECORD-UUID>');

copy & paste the generated script into the Developers Console and that solved it for now.

I hope GoDaddy will add a public DELETE endpoint to their API in the future :)

Chen Atlas
  • 101
  • 1
  • 3
  • This seems to be using api v3 and the documentation as of September 2020 is still on v1. Only 3 calls of the v2 documented. I suppose this could be used, but seems rather unreliable since it might change. – Bojidar Stanchev Sep 02 '20 at 11:38