Those who work with telephony, applications associated with calls, etc. from time to time we have to deal with the questions: “but can we determine from which region this call?” and “and which mobile operator’s number?”
In general, the answers are easy to find. The website of the Federal Communications Agency has
data on the numbering resource of all telecom operators. You go to the site, download the necessary CSV file and find the necessary information.
But you can automate this search? Of course. And many neatly parsit this CSV and put it into their database. And then use. I do that too.
')
But recently, with my colleague, we decided to pack it up a bit and make npm to quickly connect the numbering resource to the project on node.js.
Link to githab ,
link to npm .
Next, some details.
In npm there are already 4 JSON files for quick data retrieval by number. This is converted to JSON from CSV data from the site of the Federal Agency of Communications of the Russian Federation. They have the same structure as CSV: code, number range, number of numbers in a range, operator name and region.
Search by number is to search for the desired range in the file and provide data on this range.
Numcap usage example
var numcap = require('numcap'); var finder = new numcap(); finder.getData("8 (391) 274-50-00", function (err, data) { console.log(data); });
Ncli.js utility
Included is a console utility ncli.js, which can be useful in the following cases.
1. Update data. The data on the site is updated about once a month, so periodically you need to update the data.
2. Transfer data to Mongo DB. Using files is slower than using mongo database, so JSON file data can be transferred to mongo.
The description of the utility options is in the project's readme.
I hope it will be useful to you in your workings out. Constructive suggestions for improvement and additional functionality are accepted.
PS During the preparation of the utility for downloading CSV files, my colleague Alexander noticed that in the passport of open data the references to this data are incorrect. The Federal Communications Agency has promptly made adjustments to the passport of open data on the numbering resource.