Getting Started with the Name.com API
Last Updated: August 01, 2024
This guide will walk you through the process of setting up and using the Name.com API to register and manage domain names programmatically. The Name.com API provides a convenient way to automate various domain management tasks, such as registering new domains, updating DNS records, and retrieving domain information.
How the API Works
Before you begin, make sure you have the following:
- Name.com Account: You need an active account with Name.com. If you don't have one, you can sign up for an account at Name.com/account
- API Access Credentials: Obtain your API access credentials (API Username and API Token) from your Name.com account settings. You can find these under the "Account Settings" section after logging into your Name.com account.
All domains purchased through the API will also be available within your Name.com account. You can manage your domains from your Name.com account or using API commands.
When you register a domain the purchase price will be deducted from your available Account Credit balance or charged to your default payment profile if you have one. If your account credit balance is not sufficient to cover the purchase price or you do not have a default payment profile stored the domain registration will fail.
New Feature Coming Soon: You can enable Account Credit Low Balance Notification emails in your account to be notified when your account credit balance falls below a desired threshold.
Making Requests
You can make requests to the Name.com API endpoints using your preferred programming language or tools like cURL or Postman. The URL for the Name.com API is:
PRODUCTION:
https://api.name.com/v4
TEST DEVELOPMENT:
https://api.dev.name.com/v4
Examples
Domain Availability
Use CheckAvailability to check a list of up to 50 domain names to see if they are available.
curl -u 'username:token' 'https://api.dev.name.com/v4/domains:checkAvailability' -X POST -H 'Content-Type: application/json' --data '{"domainNames":["exampledomain.rocks"]}'
Replace `username` and `token` with your Username and API Token from your Name.com account.
Registering a Domain
To register a new domain using the Name.com API, send the CreateDomain API request with the domainName and any additional optional parameters such as purchasePrice and years.
curl -u 'username:token' 'https://api.dev.name.com/v4/domains' -X POST -H 'Content-Type: application/json' --data '{"domain":{"domainName":"exampledomain.rocks"},"purchasePrice":12.99}'
Updating DNS Records
To update DNS records for a domain, send the CreateRecord API request with the required DNS information.
curl -u 'username:token' 'https://api.dev.name.com/v4/domains/exampledomain.rocks/records' -X POST -H 'Content-Type: application/json' --data '{"host":"www","type":"A","answer":"10.0.0.1","ttl":300}'
Error Handling
The Name.com API returns HTTP status codes to indicate the success or failure of a request.
Common API Errors
Error: {"message":"Not Found"}
Resolution: Domain is not registered or may have expired.
Error: {"message":"Permission Denied","details":"Authentication Error - Account Has Two-Step Verification Enabled"}
Resolution: Two-Step Verification is enabled, which is not compatible with the Name.com API. Allow API Access with Two-Step Verification in your account settings.
Error: {"message":"Invalid Argument","details":"Parameter Value Error - Invalid Ipv4"}
Resolution: The DNS record is invalid.
Error: {"message":"Permission Denied"}
Resolution: The production server is https://api.name.com, and the testing server is https://api.dev.name.com. Make sure you’re using the correct environment for your requests.
Error: {"message":"Permission Denied"}
Resolution: Login credentials are incorrect.
Conclusion
Congratulations! You've now learned how to set up and use the Name.com API to register and manage domain names programmatically. For more detailed information about available endpoints and request parameters, refer to the Name.com API documentation. Happy coding!