@reallyuseful/youmail-client
v2.4.0
Published
A Node.js client for the YouMail Spam Caller API (Unofficial)
Downloads
758
Maintainers
Readme
@reallyuseful/youmail-client
A Node.js interface for the YouMail Spam Caller API (Unofficial)
Use the YouMail Spam Caller API to determine if an incoming phone call is likely to be a spammer.
const { YouMailClient } = require('@reallyuseful/youmail-client');
async function main() {
const client = new YouMailClient('your api key', 'your api sid');
// simple lookup
let result = await client.lookup('caller phone number');
// advanced lookup (passing in caller ID and/or callee)
result = await client.lookup({
callerNumber: 'caller phone number',
callerId: 'caller’s caller ID',
calledNumber: 'callee phone number'
});
console.log(result.ok); // true if the request succeeded
console.log(result.spamRisk);
// 0 = not a spammer
// 1 = possible spam
// 2 = highly likely to be spam
// undefined = no record found
console.log(result.raw);
// the full response from YouMail:
// {
// "statusCode": 10000,
// "recordFound": true,
// "phoneNumber": 9991002000,
// "spamRisk": { "level": 1 },
// "timestamp": "2016-10-06T00:31:04.362Z"
// }
}
main()
.catch(error => console.error(error))
.then(() => process.exit());