global-registrar
v1.0.9
Published
Easy access to multiple registrar APIs.
Downloads
19
Readme
Global Registrar
The goal of global-registrar is to create an easy reusable interface for multiple registrar APIs as most registrar APIs are poorly documented and/or difficult to access. The plugins for the different APIs shall recreate the same effects with the same functions. Look at the plugins pages to see what data needs to be provided.
Install
npm i global-registrar
Supported APIs
name.com - global-registrar-plugin-namecom
- Missing
- listAvailableTLD() Not supported by name.com
- Provide following plugin data:
- apiToken
- apiUsername
Gandi - global-registrar-plugin-gandi
- Missing
- setDNSSEC() Not supported by Gandi
- Provide following plugin data:
- apikey
Godaddy - global-registrar-plugin-godaddy
- Missing
- registerDomain() Not implemented: overcomplicated
- setDNSSEC() Not supported by Godaddy
- Provide following plugin data:
- apikey
- apisecret
Feel free to create your own and get it listed here!
You can also search for "global-registrar-plugin" on npm or click here.
Basic Example
test.js
(async () => {
//get global variables
require('dotenv').config();
//import the module
const {
GlobalRegistrar
} = require('global-registrar');
//create a registrar using the name.com plugin
const gr = new GlobalRegistrar({
pluginName: 'global-registrar-plugin-namecom',
pluginData: {
apiToken: process.env.NAMECOM_API_TOKEN,
apiUsername: process.env.NAMECOM_API_USERNAME,
}
});
//check if a domain is available for registration at name.com
console.log(await gr.checkAvailability('example.com'));
})();
What is dotenv?
The line "require('dotenv').config();" gets the contents of a file called ".env" in which you should store your global and secret variables.
1. Install the module "dotenv" with
npm i dotenv
2. Create a file named ".env" in your applications root directory
.env
NAMECOM_API_TOKEN='YOUR NAMECOM API KEY'
NAMECOM_API_USERNAME='YOUR NAMECOM API USERNAME'
3. Use your secret variables
process.env.NAMECOM_API_TOKEN
process.env.NAMECOM_API_USERNAME
Create your own
You can use this template: global-registrar-plugin
1 - To get started create a folder named 'global-registrar-plugin-YOUR SERVICE NAME' and navigate inside it
2 - Clone the repository by using this command (WITH THE DOT AT THE END)
git clone http://git.y.gy/firstdorsal/global-registrar-plugin.git .
3 - If you have bash installed run:
bash initGlobalRegistrarPlugin.sh
If not: replace the string PLUGINNAME manually with the name of your service in the README.md and package.json
4 - Replace the author field with your name
4.1 - Replace the repository url with your own git repository url
5 - Create your plugin
6 - To get you plugin listed here
Check if all functions produce the effects required by the documentation.
Adapt your README accordingly.
Contact me.
Need help or missing a feature?
Feel free to contact me via [email protected] in english or german
Links
Modules
Typedefs
global-registrar
- global-registrar
- .GlobalRegistrar
- new module.exports.GlobalRegistrar(plugin)
- .listAvailableTLD() ⇒ Array
- .checkAvailability(domain) ⇒ Boolean
- .checkPrice(domain) ⇒ Number | Boolean
- .registerDomain(domain, duration, registrant) ⇒ Boolean
- .renewDomain(domain, duration) ⇒ Boolean
- .getDomainInfo(domain) ⇒ Object
- .setNameServers(domain, nameservers) ⇒ Boolean
- .setDNSSEC(domain, dnssec) ⇒ Boolean
- .GlobalRegistrar
global-registrar.GlobalRegistrar
Class representing the global registrar
Kind: static class of global-registrar
- .GlobalRegistrar
- new module.exports.GlobalRegistrar(plugin)
- .listAvailableTLD() ⇒ Array
- .checkAvailability(domain) ⇒ Boolean
- .checkPrice(domain) ⇒ Number | Boolean
- .registerDomain(domain, duration, registrant) ⇒ Boolean
- .renewDomain(domain, duration) ⇒ Boolean
- .getDomainInfo(domain) ⇒ Object
- .setNameServers(domain, nameservers) ⇒ Boolean
- .setDNSSEC(domain, dnssec) ⇒ Boolean
new module.exports.GlobalRegistrar(plugin)
Create a global registrar client
| Param | Type | Description | | --- | --- | --- | | plugin | Object | a plugin object with its name and required data |
Example
const gr = new GlobalRegistrar({
pluginName: 'global-registrar-plugin-gandi',
pluginData: {
apikey: process.env.GANDI_API_KEY
}
});
globalRegistrar.listAvailableTLD() ⇒ Array
Retrieves list of available tld names. Must return array with all available tld endings and nothing else.
Kind: instance method of GlobalRegistrar
Returns: Array - Array of top level domains
Example
await gr.listAvailableTLD()
globalRegistrar.checkAvailability(domain) ⇒ Boolean
Checks if domain is publicly available for registration at the registrar. Takes domain name as string. Has to return true if domain is available and false if not. Null will be returned if the check couldnt be performed or an error occurs.
Kind: instance method of GlobalRegistrar
Returns: Boolean - True if domain is available for registration
| Param | Type | Description | | --- | --- | --- | | domain | String | The domain you want to check for |
Example
await gr.checkAvailability('example.com')
globalRegistrar.checkPrice(domain) ⇒ Number | Boolean
Checks if domain is publicly available for registration at the registrar. Takes domain name as string. Returns the pricing information from the registrar or false if domain is not available for registration
Kind: instance method of GlobalRegistrar
Returns: Number | Boolean - price in USD for one year without taxes, false or null
| Param | Type | Description | | --- | --- | --- | | domain | String | The domain you want to check for |
Example
await gr.checkPrice('paulisttoll.eu')
globalRegistrar.registerDomain(domain, duration, registrant) ⇒ Boolean
Registers a domain
Kind: instance method of GlobalRegistrar
| Param | Type | Description | | --- | --- | --- | | domain | String | The domain you want to register | | duration | Number | The duration to register the domain for in years. | | registrant | Registrant | A Registrant object with information about the registrant must be provided |
Example
await gr.registerDomain("paulisttoll.eu", 1, {
email: "[email protected]",
lastName: "Müller",
firstName: "Karl",
registrantType: 0,
country: "Deutschland",
countryCode: "DE",
state: "Bayern",
city: "Augsburg",
zip: "86150",
street: "Musterstraße",
houseNumber: "42",
phone: '+491234567890'
})
globalRegistrar.renewDomain(domain, duration) ⇒ Boolean
Renews a domain.
Kind: instance method of GlobalRegistrar
| Param | Type | Description | | --- | --- | --- | | domain | String | The domain you want to renew | | duration | Number | The duration to renew the domain for in years. |
Example
await gr.renewDomain("paulisttoll.eu", 2)
//will prolong the registration of the domain paulisttoll.eu by 2 years
globalRegistrar.getDomainInfo(domain) ⇒ Object
Gives back information about the registration of a domain
Kind: instance method of GlobalRegistrar
Returns: Object - information about the domain
| Param | Type | Description | | --- | --- | --- | | domain | String | The domain you want to get information about |
Example
await gr.getDomainInfo('paulisttoll.eu')
globalRegistrar.setNameServers(domain, nameservers) ⇒ Boolean
Sets the nameservers for a domain
Kind: instance method of GlobalRegistrar
Returns: Boolean - true on success
| Param | Type | Description | | --- | --- | --- | | domain | String | The domain you want to set the nameservers for | | nameservers | Array | Array with the domain names of all nameservers |
Example
await gr.setNameServers('paulisttoll.eu',["tick.y.gy","trick.y.gy","track.y.gy"])
globalRegistrar.setDNSSEC(domain, dnssec) ⇒ Boolean
Sets the dnssec parameters for a domain at the registrar
Kind: instance method of GlobalRegistrar
Returns: Boolean - true on success
| Param | Type | Description | | --- | --- | --- | | domain | String | The domain you want to set the nameservers for | | dnssec | Dnssec | Dnssec object with the dnssec parameters |
Example
await gr.setNameServers('paulisttoll.eu',{
"keyTag": 30909,
"algorithm": 8,
"digestType": 2,
"digest": "E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CFC41A5766"
})
Dnssec : Object
Object representing the dnssec data
Kind: global typedef
Properties
| Name | Type | | --- | --- | | keyTag | Number | | algorithm | Number | | digestType | Number | | digest | String |
Example
{
"keyTag": 30909,
"algorithm": 8,
"digestType": 2,
"digest": "E2D3C916F6DEEAC73294E8268FB5885044A833FC5459588F4A9184CFC41A5766"
}
Registrant : Object
Object representing a registrant
Kind: global typedef
Properties
| Name | Type | Description | | --- | --- | --- | | email | String | The email address of the registrant | | lastName | String | The last name/"family name" of the registrant | | firstName | String | The first name/"given name" of the registrant | | registrantType | 0 | 1 | 2 | 3 | 4 | the type of the registrant: 0=person, 1=company, 2=association, 3=public body, 4=reseller | | country | String | The country the registrant is coming from | | countryCode | String | The country the registrant is coming from provided as ISO-3166 country code | | state | String | The province/state the registrant is coming from | | city | String | The city the registrant is coming from | | zip | String | The zip code the registrant is coming from | | street | String | The street the registrant is coming from | | houseNumber | String | The house number the registrant is coming from | | phone | String | The registrants phone number |
Example
{
email: "[email protected]",
lastName: "Müller",
firstName: "Karl",
registrantType: 0,
country: "Deutschland",
countryCode: "DE",
state: "Bayern",
city: "Augsburg",
zip: "86150",
street: "Musterstraße",
houseNumber: "42",
phone: '+491234567890'
}