Skip to content

Commit b5ed42e

Browse files
committed
Added readthedocs documentation.
1 parent a3a71df commit b5ed42e

File tree

10 files changed

+310
-0
lines changed

10 files changed

+310
-0
lines changed

.readthedocs.yaml

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# .readthedocs.yaml
2+
# Read the Docs configuration file
3+
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
4+
5+
# Required
6+
version: 2
7+
8+
# Set the OS, Python version and other tools you might need
9+
build:
10+
os: ubuntu-22.04
11+
tools:
12+
python: "3.11"
13+
# You can also specify other tool versions:
14+
# nodejs: "19"
15+
# rust: "1.64"
16+
# golang: "1.19"
17+
18+
# Build documentation in the "docs/" directory with Sphinx
19+
sphinx:
20+
configuration: docs/source/conf.py
21+
22+
# Optionally build your docs in additional formats such as PDF and ePub
23+
# formats:
24+
# - pdf
25+
# - epub
26+
27+
# Optional but recommended, declare the Python requirements required
28+
# to build your documentation
29+
# See https://docs.readthedocs.io/en/stable/guides/reproducible-builds.html
30+
python:
31+
install:
32+
- requirements: docs/requirements.txt

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line, and also
5+
# from the environment for the first two.
6+
SPHINXOPTS ?=
7+
SPHINXBUILD ?= sphinx-build
8+
SOURCEDIR = source
9+
BUILDDIR = build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/make.bat

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
@ECHO OFF
2+
3+
pushd %~dp0
4+
5+
REM Command file for Sphinx documentation
6+
7+
if "%SPHINXBUILD%" == "" (
8+
set SPHINXBUILD=sphinx-build
9+
)
10+
set SOURCEDIR=source
11+
set BUILDDIR=build
12+
13+
%SPHINXBUILD% >NUL 2>NUL
14+
if errorlevel 9009 (
15+
echo.
16+
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
17+
echo.installed, then set the SPHINXBUILD environment variable to point
18+
echo.to the full path of the 'sphinx-build' executable. Alternatively you
19+
echo.may add the Sphinx directory to PATH.
20+
echo.
21+
echo.If you don't have Sphinx installed, grab it from
22+
echo.https://www.sphinx-doc.org/
23+
exit /b 1
24+
)
25+
26+
if "%1" == "" goto help
27+
28+
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
29+
goto end
30+
31+
:help
32+
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
33+
34+
:end
35+
popd

docs/requirements.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Defining the exact version will make sure things don't break
2+
sphinx-book-theme==1.0.1
3+
# sphinx-pdj-theme==0.4.0
4+
myst-parser==2.0.0
5+
markdown-it-py==3.0.0
6+
sphinx-copybutton==0.5.2

docs/source/code.md

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
# IP2Proxy Node.js API
2+
3+
## IP2Proxy Class
4+
```{py:class} IP2Proxy()
5+
Construct the IP2Location Class.
6+
```
7+
8+
```{py:function} open(binPath)
9+
Load the IP2Proxy BIN database for lookup.
10+
11+
:param str binPath: (Required) The file path links to IP2Proxy BIN databases.
12+
```
13+
14+
```{py:function} getPackageVersion()
15+
Return the database's type, 1 to 10 respectively for PX1 to PX11. Please visit https://www.ip2location.com/databases/ip2proxy for details.
16+
17+
:return: Returns the package version.
18+
:rtype: string
19+
```
20+
21+
```{py:function} getModuleVersion()
22+
Return the version of module.
23+
24+
:return: Returns the module version.
25+
:rtype: string
26+
```
27+
28+
```{py:function} getDatabaseVersion()
29+
Return the database's compilation date as a string of the form 'YYYY-MM-DD'.
30+
31+
:return: Returns the database version.
32+
:rtype: string
33+
```
34+
35+
```{py:function} getAll(ipAddress)
36+
Retrieve geolocation information for an IP address.
37+
38+
:param string ipAddress: (Required) The IP address (IPv4 or IPv6).
39+
:return: Returns the geolocation information in array. Refer below table for the fields avaliable in the array
40+
:rtype: array
41+
42+
**RETURN FIELDS**
43+
44+
| Field Name | Description |
45+
| ---------------- | ------------------------------------------------------------ |
46+
| countryCode | Two-character country code based on ISO 3166. |
47+
| countryName | Country name based on ISO 3166. |
48+
| regionName | Region or state name. |
49+
| cityName | City name. |
50+
| isp | Internet Service Provider or company\'s name. |
51+
| domain | Internet domain name associated with IP address range. |
52+
| usageType | Usage type classification of ISP or company. |
53+
| asn | Autonomous system number (ASN). |
54+
| as | Autonomous system (AS) name. |
55+
| lastSeen | Proxy last seen in days. |
56+
| threat | Security threat reported. |
57+
| proxyType | Type of proxy. |
58+
| provider | Name of VPN provider if available. |
59+
```

docs/source/conf.py

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
# Configuration file for the Sphinx documentation builder.
2+
# Read https://www.sphinx-doc.org/en/master/usage/configuration.html for more options available
3+
4+
# -- Project information
5+
6+
project = 'IP2Proxy PHP'
7+
copyright = '2023, IP2Location'
8+
author = 'IP2Location'
9+
10+
release = '0.1.0'
11+
version = '0.1.0'
12+
13+
# -- General configuration
14+
15+
extensions = [
16+
'sphinx.ext.duration',
17+
'sphinx.ext.doctest',
18+
'myst_parser',
19+
'sphinx_copybutton',
20+
]
21+
22+
# https://myst-parser.readthedocs.io/en/latest/syntax/optional.html
23+
24+
myst_enable_extensions = [
25+
"colon_fence",
26+
"deflist",
27+
"fieldlist",
28+
]
29+
30+
# https://myst-parser.readthedocs.io/en/latest/configuration.html#setting-html-metadata
31+
myst_html_meta = {
32+
"description": "IP2Proxy Node.js library enables user to query an IP address if it was being used as open proxy, web proxy, VPN anonymizer and TOR exits.",
33+
"keywords": "IP2Proxy, Proxy, IP location, NodeJS",
34+
"google-site-verification": "DeW6mXDyMnMt4i61ZJBNuoADPimo5266DKob7Z7d6i4",
35+
}
36+
37+
# templates_path = ['_templates']
38+
39+
# -- Options for HTML output
40+
41+
html_theme = 'sphinx_book_theme'
42+
43+
html_theme_options = {
44+
"use_edit_page_button": False,
45+
"use_source_button": False,
46+
"use_issues_button": False,
47+
"use_download_button": False,
48+
"use_sidenotes": False,
49+
}
50+
}
51+
52+
# The name of an image file (relative to this directory) to place at the top
53+
# of the sidebar.
54+
html_logo = 'images/ipl-logo-square-1200.png'
55+
56+
# Favicon
57+
html_favicon = 'images/favicon.ico'
58+
59+
html_title = "IP2Proxy Node.js"
60+
61+
html_baseurl = "https://ip2proxy-nodejs.readthedocs.io/en/latest/"

docs/source/images/favicon.ico

14.7 KB
Binary file not shown.
19.8 KB
Loading

docs/source/index.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
[![npm](https://img.shields.io/npm/v/ip2proxy-nodejs.svg)](http://npm.im/ip2proxy-nodejs)
2+
[![npm](https://img.shields.io/npm/dm/ip2proxy-nodejs.svg)](http://npm.im/ip2proxy-nodejs)
3+
4+
# IP2Proxy Node.js Module
5+
6+
This module allows user to query an IP address if it was being used as VPN anonymizer, open proxies, web proxies, Tor exits, data center, web hosting (DCH) range, search engine robots (SES) and residential (RES). It lookup the proxy IP address from **IP2Proxy BIN Data** file. This data file can be downloaded at
7+
8+
* Free IP2Proxy BIN Data: https://lite.ip2location.com
9+
* Commercial IP2Proxy BIN Data: https://www.ip2location.com/database/ip2proxy
10+
11+
12+
13+
14+
## Table of contents
15+
```{eval-rst}
16+
.. toctree::
17+
18+
self
19+
quickstart
20+
code
21+
```

docs/source/quickstart.md

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Quickstart
2+
3+
## Dependencies
4+
5+
This library requires IP2Proxy BIN database to function. You may download the BIN database at
6+
7+
- IP2Proxy LITE BIN Data (Free): <https://lite.ip2location.com>
8+
- IP2Proxy Commercial BIN Data (Comprehensive):
9+
<https://www.ip2location.com>
10+
11+
## Installation
12+
13+
Install this package using the command as below:
14+
15+
```bash
16+
17+
npm install ip2proxy-nodejs
18+
19+
```
20+
21+
## Sample Codes
22+
23+
### Query geolocation information from BIN database
24+
25+
You can query the geolocation information from the IP2Proxy BIN database as below:
26+
27+
```javascript
28+
const {IP2Proxy} = require("ip2proxy-nodejs");
29+
30+
let ip2proxy = new IP2Proxy();
31+
32+
if (ip2proxy.open("./IP2PROXY-IP-PROXYTYPE-COUNTRY-REGION-CITY-ISP-DOMAIN-USAGETYPE-ASN-LASTSEEN-THREAT-RESIDENTIAL-PROVIDER.BIN") == 0) {
33+
ip = '199.83.103.79';
34+
35+
console.log("GetModuleVersion: " + ip2proxy.getModuleVersion());
36+
console.log("GetPackageVersion: " + ip2proxy.getPackageVersion());
37+
console.log("GetDatabaseVersion: " + ip2proxy.getDatabaseVersion());
38+
39+
// functions for individual fields
40+
console.log("isProxy: " + ip2proxy.isProxy(ip));
41+
console.log("ProxyType: " + ip2proxy.getProxyType(ip));
42+
console.log("CountryShort: " + ip2proxy.getCountryShort(ip));
43+
console.log("CountryLong: " + ip2proxy.getCountryLong(ip));
44+
console.log("Region: " + ip2proxy.getRegion(ip));
45+
console.log("City: " + ip2proxy.getCity(ip));
46+
console.log("ISP: " + ip2proxy.getISP(ip));
47+
console.log("Domain: " + ip2proxy.getDomain(ip));
48+
console.log("UsageType: " + ip2proxy.getUsageType(ip));
49+
console.log("ASN: " + ip2proxy.getASN(ip));
50+
console.log("AS: " + ip2proxy.getAS(ip));
51+
console.log("LastSeen: " + ip2proxy.getLastSeen(ip));
52+
console.log("Threat: " + ip2proxy.getThreat(ip));
53+
console.log("Provider: " + ip2proxy.getProvider(ip));
54+
55+
// function for all fields
56+
let all = ip2proxy.getAll(ip);
57+
console.log("isProxy: " + all.isProxy);
58+
console.log("proxyType: " + all.proxyType);
59+
console.log("countryShort: " + all.countryShort);
60+
console.log("countryLong: " + all.countryLong);
61+
console.log("region: " + all.region);
62+
console.log("city: " + all.city);
63+
console.log("isp: " + all.isp);
64+
console.log("domain: " + all.domain);
65+
console.log("usagetype: " + all.usageType);
66+
console.log("asn: " + all.asn);
67+
console.log("as: " + all.as);
68+
console.log("lastSeen: " + all.lastSeen);
69+
console.log("threat: " + all.threat);
70+
console.log("provider: " + all.provider);
71+
}
72+
else {
73+
console.log("Error reading BIN file.");
74+
}
75+
ip2proxy.close();
76+
```

0 commit comments

Comments
 (0)