new GetSMS(options) → {GetSMS}
GetSMS class constructor
Parameters:
Name | Type | Description |
---|---|---|
options | InitProperties | Options object |
Throws:
Error
Returns:
- Type:
- GetSMS
Methods
(async) getAdditionalService(id, service) → {Promise.<additionalServiceResponse>}
Method for getting additional service for numbers with forward (only for smsactivate)
Parameters:
Name | Type | Description |
---|---|---|
id | string | Mobile number ID |
service | string | Service code name |
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<additionalServiceResponse>
(async) getBalance() → {Promise.<BalanceObject>}
Method for getting account balance
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<BalanceObject>
(async) getCode(id, timeoutopt) → {Promise.<getCodeResponse>}
Method which polling with getStatus method and returns new status when it's changes
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
id | string | | Mobile number ID | ||
timeout | number | <optional> | 0 | Timeout, after reached - forcefully stop and throw `TimeoutError`, pass 0 to disable |
Throws:
Error | ServiceApiError | TimeoutError
Returns:
- Type:
- Promise.<getCodeResponse>
Example
const { id, number } = await sms.getNumber('vk', 'mts', 0)
console.log('Number ID:', id);
console.log('Number:', number);
await sms.setStatus(1, id);
// Wait for code
const { code } = await sms.getCode(id)
console.log('Code:', code)
await sms.setStatus(1, id) //Accept, end
(async) getCountries() → {Promise.<object>}
Method for getting countries list (only for smsactivate)
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>
(async) getCurrentActivations() → {Promise.<object>}
Unofficial / hidden method for getting list of current activations (only for smshub)
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>
Example
Answer example:
// Success request:
{
status: 'success',
array: [
{
id: '1231231231',
activationId: '1231231231',
apiKeyId: '12345',
phone: '79538364598',
status: '2',
moreCodes: '',
createDate: 1654770955,
receiveSmsDate: -62169993017,
finishDate: '0000-00-00 00:00:00',
activation: [Object],
code: '<img src="/assets/ico/loading.gif" width="50px"></img>',
countryCode: '7',
countryName: 'Россия',
timer: 1200
}
],
time: 1654770985
}
// No activations:
{ status: 'fail', msg: 'no_activations' }
(async) getFullSms(id) → {Promise.<fullSMSTextResponse>}
Method for getting full sms text (only for smsactivate)
Parameters:
Name | Type | Description |
---|---|---|
id | string | | Mobile number ID |
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<fullSMSTextResponse>
(async) getListOfCountriesAndOperators() → {Promise.<object>}
Unofficial / hidden method for getting list of countries & operators (only for smshub)
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>
Example
Answer example:
{
status: "success",
services: [{
lb: "Mailru Group",
vk: "Вконтакте",
ok: "Ok.ru",
// ...
ot: "Любой другой"
},
// ...
],
data: [{
name: "Индонезия",
id: "6",
operators: ["any", "axis", "indosat", "smartfren", "telkomsel", "three"]
}],
currentCountry: "0",
currentOperator: "any"
}
(async) getMultiServiceNumber(service, operator, country, forwardopt, refopt) → {Promise.<object>}
Method for getting number for using with several services (only for smsactivate)
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
service | array | | Array of services names | |
operator | array | | Array of operators names | |
country | string | | Country ID | |
forward | Array.<(string|number)> | | <optional> | Number forward, must have values 1 or 0 * |
ref | string | <optional> | Referral identifier |
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>
Examples
.getMultiServiceNumber('ok,vk,vi,av', 'mts', 0, '0,1,0,0')
.getMultiServiceNumber(['ok','vk','vi','av'], 'mts', 0, [0, 1, 0, 0])
(async) getNumber(service, operatoropt, countryopt, forwardopt, phoneExceptionopt, refopt) → {Promise.<object>}
Method for getting new number Arguments with * available only for smsactivate
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
service | string | Service code name | |
operator | string | <optional> | Mobile operator code name |
country | string | | <optional> | Country ID |
forward | string | | <optional> | Number forward, must be `1` or `0` * |
phoneException | string | <optional> | Prefixes for excepting mobile numbers separated by comma * |
ref | string | <optional> | Referral identifier * |
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>
(async) getNumbersStatus(countryopt, operatoropt) → {object}
Method for getting number status
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
country | string | | <optional> | Country ID |
operator | string | <optional> | Mobile operator code name |
Throws:
Error | ServiceApiError
Returns:
- Type:
- object
(async) getPrices(countryopt, service) → {Promise.<object>}
Method for getting numbers prices
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
country | string | | <optional> | Country ID |
service | string | Service code name |
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>
(async) getQiwiRequisites() → {Promise.<object>}
Method for getting Qiwi payment requisites (only for smsactivate)
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>
(async) getStatus(id) → {Promise.<object>}
Method for getting number status
Parameters:
Name | Type | Description |
---|---|---|
id | string | | Mobile number ID |
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>
(async) setMaxPrice(service, maxPrice, random, country) → {Promise}
Unofficial / hidden method for changing default number settings (only for smshub) Change max price of mobile number for country id, enable / disable random
WARNING: I don't know why, but really values changed only after ~30 seconds, maybe it's cached on smshub server
Parameters:
Name | Type | Default | Description |
---|---|---|---|
service | string | Service code name | |
maxPrice | string | | Max buy price | |
random | boolean | true | Enable random number |
country | string | | Country ID |
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise
(async) setStatus(status, id) → {Promise.<object>}
Method for set number status
Parameters:
Name | Type | Description |
---|---|---|
status | string | | New mobile number status |
id | string | | Mobile number ID |
Throws:
Error | ServiceApiError
Returns:
- Type:
- Promise.<object>