init
This commit is contained in:
42 files changed
+1617
No files matched your search
@@ -0,0 +1,178 @@
|
||||
# Jahan Nama / Webotel API Documentation
|
||||
|
||||
This document describes the HTTP API used to authenticate a Jahan Nama/Webotel user and retrieve the user's remaining internet traffic. It is written for anyone building an independent client.
|
||||
|
||||
## Base URL
|
||||
|
||||
```text
|
||||
https://qomservice.webotel.ir
|
||||
```
|
||||
|
||||
## Endpoints
|
||||
|
||||
| Purpose | Method | Path |
|
||||
| --- | --- | --- |
|
||||
| Authenticate user | `POST` | `/api/login/AuthenticateWeb` |
|
||||
| Get remaining traffic | `GET` | `/api/BaseInfo/GetUserRemain` |
|
||||
|
||||
## Common Headers
|
||||
|
||||
Clients should send:
|
||||
|
||||
```http
|
||||
Accept: application/json
|
||||
User-Agent: Mozilla/5.0
|
||||
```
|
||||
|
||||
The API returns JSON responses.
|
||||
|
||||
## Authentication
|
||||
|
||||
Authenticate with the user's username and password to receive an access token.
|
||||
|
||||
### Request
|
||||
|
||||
```http
|
||||
POST /api/login/AuthenticateWeb HTTP/1.1
|
||||
Host: qomservice.webotel.ir
|
||||
Accept: application/json
|
||||
User-Agent: Mozilla/5.0
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
```
|
||||
|
||||
Form fields:
|
||||
|
||||
| Field | Required | Description |
|
||||
| --- | --- | --- |
|
||||
| `Username` | Yes | The user's account username. |
|
||||
| `Password` | Yes | The user's account password. |
|
||||
| `DeviceTypeEnum` | Yes | Device type value. Existing clients use `4`. |
|
||||
| `IP` | No | IP value. Existing clients send an empty string. |
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
curl -X POST 'https://qomservice.webotel.ir/api/login/AuthenticateWeb' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'User-Agent: Mozilla/5.0' \
|
||||
-H 'Content-Type: application/x-www-form-urlencoded' \
|
||||
--data-urlencode 'Username=YOUR_USERNAME' \
|
||||
--data-urlencode 'Password=YOUR_PASSWORD' \
|
||||
--data-urlencode 'DeviceTypeEnum=4' \
|
||||
--data-urlencode 'IP='
|
||||
```
|
||||
|
||||
### Response
|
||||
|
||||
The response is expected to be a JSON object containing a token:
|
||||
|
||||
```json
|
||||
{
|
||||
"Token": "ACCESS_TOKEN"
|
||||
}
|
||||
```
|
||||
|
||||
The response may include additional fields. A client should treat authentication as successful only when `Token` exists and is a non-empty string.
|
||||
|
||||
## Get Remaining Traffic
|
||||
|
||||
Use the authentication token to fetch the remaining traffic.
|
||||
|
||||
### Request
|
||||
|
||||
```http
|
||||
GET /api/BaseInfo/GetUserRemain?Token=ACCESS_TOKEN HTTP/1.1
|
||||
Host: qomservice.webotel.ir
|
||||
Accept: application/json
|
||||
User-Agent: Mozilla/5.0
|
||||
```
|
||||
|
||||
Query parameters:
|
||||
|
||||
| Parameter | Required | Description |
|
||||
| --- | --- | --- |
|
||||
| `Token` | Yes | Token returned by `/api/login/AuthenticateWeb`. |
|
||||
|
||||
Example:
|
||||
|
||||
```sh
|
||||
curl 'https://qomservice.webotel.ir/api/BaseInfo/GetUserRemain?Token=ACCESS_TOKEN' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'User-Agent: Mozilla/5.0'
|
||||
```
|
||||
|
||||
### Response
|
||||
|
||||
The response is expected to be a JSON object containing `RemainTraffic`:
|
||||
|
||||
```json
|
||||
{
|
||||
"RemainTraffic": 1536
|
||||
}
|
||||
```
|
||||
|
||||
The response may include additional fields. `RemainTraffic` is the remaining traffic amount in megabytes.
|
||||
|
||||
Known accepted value shapes:
|
||||
|
||||
```json
|
||||
{ "RemainTraffic": 1536 }
|
||||
```
|
||||
|
||||
```json
|
||||
{ "RemainTraffic": "1536" }
|
||||
```
|
||||
|
||||
Client implementations should accept `RemainTraffic` as either a JSON number or a numeric string. Other JSON types should be treated as invalid for this field.
|
||||
|
||||
## Recommended Client Flow
|
||||
|
||||
1. Send username and password to `/api/login/AuthenticateWeb`.
|
||||
2. Read the `Token` field from the authentication response.
|
||||
3. Store the token securely for reuse.
|
||||
4. Call `/api/BaseInfo/GetUserRemain` with `Token` as a query parameter.
|
||||
5. Read `RemainTraffic` from the response.
|
||||
6. If the token request fails with `401 Unauthorized` or `403 Forbidden`, authenticate again and retry the remaining-traffic request once.
|
||||
7. If the remaining-traffic response does not contain a valid `RemainTraffic` value, treat the response as an API error.
|
||||
|
||||
## Token Handling
|
||||
|
||||
The API token is passed as a query parameter, not as an `Authorization` header.
|
||||
|
||||
```text
|
||||
/api/BaseInfo/GetUserRemain?Token=ACCESS_TOKEN
|
||||
```
|
||||
|
||||
No refresh-token endpoint is known from the observed client behavior. When a token expires or is rejected, clients should authenticate again with username and password.
|
||||
|
||||
Because the token grants access to account information, clients should store it securely and avoid logging it.
|
||||
|
||||
## Traffic Unit Formatting
|
||||
|
||||
`RemainTraffic` is returned in megabytes.
|
||||
|
||||
Example conversions:
|
||||
|
||||
| Raw value | Meaning | Display example |
|
||||
| --- | --- | --- |
|
||||
| `512` | 512 MB | `512.00 MB` |
|
||||
| `1536` | 1536 MB | `1.50 GB` |
|
||||
|
||||
A common display rule is:
|
||||
|
||||
- If `RemainTraffic` is less than `1024`, show it as MB.
|
||||
- If `RemainTraffic` is `1024` or greater, divide by `1024` and show it as GB.
|
||||
|
||||
## Error Handling
|
||||
|
||||
Clients should handle these cases:
|
||||
|
||||
| Case | Recommended handling |
|
||||
| --- | --- |
|
||||
| Network error or timeout | Report a request failure and allow retry. |
|
||||
| Non-2xx HTTP status | Treat as request failure. Re-authenticate once for `401` or `403`. |
|
||||
| Authentication response missing `Token` | Treat as authentication failure. |
|
||||
| Remaining-traffic response missing `RemainTraffic` | Treat as unexpected API response. |
|
||||
| `RemainTraffic` is not numeric | Treat as unexpected API response. |
|
||||
| Invalid JSON response | Treat as unexpected API response. |
|
||||
|
||||
+141
@@ -0,0 +1,141 @@
|
||||
# Authenticate
|
||||
|
||||
## Create session
|
||||
|
||||
### request
|
||||
|
||||
```bash
|
||||
curl 'https://my.mci.ir/api/idm/v1/auth' \
|
||||
-X POST \
|
||||
-H 'User-Agent: Mozilla/5.0' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Origin: https://my.mci.ir' \
|
||||
-H 'Referer: https://my.mci.ir' \
|
||||
-H 'platform: WEB' \
|
||||
-H 'version: 1.29.0' \
|
||||
--data-raw '{"username":"9123456789","credential":"xxxx","credential_type":"PASSWORD"}'
|
||||
```
|
||||
|
||||
### response
|
||||
|
||||
```json
|
||||
{
|
||||
"access_token": "eyJhbG...",
|
||||
"expires_in": 1800,
|
||||
"refresh_token": "eyJhbG...",
|
||||
"refresh_expires_in": 2522000,
|
||||
"session_state": "111_222_333"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Refresh session
|
||||
|
||||
### request
|
||||
|
||||
```bash
|
||||
curl 'https://my.mci.ir/api/idm/v1/auth' \
|
||||
-X POST \
|
||||
-H 'Authorization: Bearer eyJhbG...' \
|
||||
-H 'User-Agent: Mozilla/5.0' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Origin: https://my.mci.ir' \
|
||||
-H 'Referer: https://my.mci.ir' \
|
||||
-H 'platform: WEB' \
|
||||
-H 'version: 1.29.0' \
|
||||
--data-raw '{"username":"9123456789","credential_type":"REFRESH_TOKEN","credential":"eyJhbG..."}'
|
||||
```
|
||||
|
||||
### response
|
||||
|
||||
```json
|
||||
{
|
||||
"access_token": "eyJhbG...",
|
||||
"expires_in": 1800,
|
||||
"refresh_token": "eyJhbG...",
|
||||
"refresh_expires_in": 2522000,
|
||||
"session_state": "111_222_333"
|
||||
}
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
# Packages
|
||||
|
||||
## Refresh session
|
||||
|
||||
### request
|
||||
|
||||
```bash
|
||||
curl 'https://my.mci.ir/api/unit/v1/packages/details' \
|
||||
-H 'User-Agent: Mozilla/5.0' \
|
||||
-H 'Accept: application/json' \
|
||||
-H 'Content-Type: application/json' \
|
||||
-H 'Origin: https://my.mci.ir' \
|
||||
-H 'Referer: https://my.mci.ir' \
|
||||
-H 'platform: WEB' \
|
||||
-H 'version: 1.29.0' \
|
||||
-H 'Authorization: Bearer eyJhbG...'
|
||||
```
|
||||
|
||||
### response
|
||||
|
||||
```json
|
||||
{
|
||||
"packageItems": [
|
||||
{
|
||||
"type": "internet",
|
||||
"formattedExpireTime": "۱۵:۵۵:۱۳ - ۱۴۰۵/۰۵/۰۴",
|
||||
"expireTime": "2026-07-26T15:55:13",
|
||||
"effectiveTime": "2026-03-28T15:55:13",
|
||||
"formattedEffectiveTime": "۱۵:۵۵:۱۳ - ۱۴۰۵/۰۱/۰۸",
|
||||
"remainingDays": "111 روز باقیمانده",
|
||||
"totalInitValue": 100.06,
|
||||
"totalUnusedValue": 12.71,
|
||||
"totalUnitName": "گیگ",
|
||||
"unUsedUnitName": "گیگ",
|
||||
"packageStatus": "active",
|
||||
"packageStatusText": "فعال",
|
||||
"offerName": "بسته اینترنت 120 روزه 100 گیگابایت",
|
||||
"remainingText": "باقی مانده از",
|
||||
"offeringId": "501460",
|
||||
"itemDetails": [
|
||||
{
|
||||
"colourCodeUnused": "#00AECD",
|
||||
"colourCodeUsed": "#F1F5F9",
|
||||
"colourCodeUsedDark": "#101214",
|
||||
"shortName": "12.71 گیگ عادی",
|
||||
"initAmount": 107437096960,
|
||||
"unusedAmount": 13651190514,
|
||||
"freeUnitType": "C_5007",
|
||||
"offeringId": "501460",
|
||||
"internalItemDetails": [
|
||||
"معادل 34.36 گیگ ترافیک داخلی",
|
||||
"معادل 50.85 گیگ پیام رسان داخلی"
|
||||
]
|
||||
}
|
||||
],
|
||||
"freeUnit": true,
|
||||
"autoRenewal": false,
|
||||
"isFreeUnit": true,
|
||||
"isAutoRenewal": false
|
||||
}
|
||||
],
|
||||
"totalInitBytes": 100.06,
|
||||
"totalUnusedBytes": 12.71,
|
||||
"bytesInitUnit": "گیگ",
|
||||
"bytesUnit": "گیگ",
|
||||
"bytesUnusedUnit": "گیگ",
|
||||
"totalInitMessages": 0.0,
|
||||
"totalUnusedMessages": 0.0,
|
||||
"messagesUnit": "عدد",
|
||||
"totalInitCall": 0.0,
|
||||
"totalUnusedCall": 0.0,
|
||||
"showableTextCall": "باقی مانده از",
|
||||
"showableTextBytes": "باقی مانده از",
|
||||
"showableTextMessage": "باقی مانده از"
|
||||
}
|
||||
```
|
||||
+286
@@ -0,0 +1,286 @@
|
||||
# TCI Internet Portal HTTP API
|
||||
|
||||
This document describes the HTTP workflow used by the TCI Internet customer portal. It is written as implementation-independent API documentation so it can be used to build clients in any language.
|
||||
|
||||
The portal is not a JSON REST API. It is a session-based web application that returns HTML pages, uses HTTP cookies for authentication state, and requires solving an image captcha during login.
|
||||
|
||||
## Base URL
|
||||
|
||||
```text
|
||||
https://internet.tci.ir
|
||||
```
|
||||
|
||||
All relative URLs discovered in HTML responses should be resolved against this base URL.
|
||||
|
||||
## Session Model
|
||||
|
||||
The portal uses standard HTTP cookies.
|
||||
|
||||
Clients must:
|
||||
|
||||
1. Store cookies from every response.
|
||||
2. Send stored cookies with every later request.
|
||||
3. Persist cookies if long-lived sessions are desired.
|
||||
4. Re-login when the stored session is expired or invalid.
|
||||
|
||||
A practical way to detect an authenticated session is to request `GET /panel` and check whether the returned HTML contains a logout marker such as:
|
||||
|
||||
```text
|
||||
logout
|
||||
خروج
|
||||
```
|
||||
|
||||
If neither marker is present, treat the session as unauthenticated.
|
||||
|
||||
## Common Headers
|
||||
|
||||
The portal works with ordinary browser-like HTTP requests. At minimum, clients should support compressed responses and redirects.
|
||||
|
||||
Recommended request behavior:
|
||||
|
||||
```text
|
||||
Accept-Encoding: gzip, deflate, br
|
||||
```
|
||||
|
||||
Clients should:
|
||||
|
||||
- Follow redirects for login requests.
|
||||
- Preserve cookies across redirects.
|
||||
- Decode compressed responses.
|
||||
- Submit form data as `application/x-www-form-urlencoded`.
|
||||
|
||||
## Authentication Flow
|
||||
|
||||
### 1. Fetch Login Page
|
||||
|
||||
```http
|
||||
GET /panel HTTP/1.1
|
||||
Host: internet.tci.ir
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
- Starts or resumes a portal session.
|
||||
- Returns either the authenticated panel HTML or the login page HTML.
|
||||
- Sets initial cookies needed for captcha and login.
|
||||
|
||||
If the response already contains an authenticated marker such as `logout` or `خروج`, the client can skip the login flow.
|
||||
|
||||
If the response is a login page, parse the HTML for:
|
||||
|
||||
- The login form `action` URL.
|
||||
- The captcha image URL.
|
||||
|
||||
The captcha image is inside an image element with:
|
||||
|
||||
```html
|
||||
id="loginCaptchaImage"
|
||||
```
|
||||
|
||||
The form action and captcha image source may be absolute or relative URLs. Resolve relative values against `https://internet.tci.ir`.
|
||||
|
||||
### 2. Download Captcha Image
|
||||
|
||||
```http
|
||||
GET {captcha_url} HTTP/1.1
|
||||
Host: internet.tci.ir
|
||||
Cookie: ...
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
- Downloads the captcha image associated with the current cookie session.
|
||||
|
||||
The response body is image data, typically suitable to save or display as a JPEG image. The captcha value must be solved by a user or by a separate OCR/captcha-solving process.
|
||||
|
||||
Important:
|
||||
|
||||
- Use the same cookie jar/session used for `GET /panel`.
|
||||
- Do not fetch the captcha with a different session; the submitted captcha must match the session that received the image.
|
||||
|
||||
### 3. Submit Login Form
|
||||
|
||||
```http
|
||||
POST {login_action_url} HTTP/1.1
|
||||
Host: internet.tci.ir
|
||||
Content-Type: application/x-www-form-urlencoded
|
||||
Cookie: ...
|
||||
|
||||
username={username}&password={password}&captcha={captcha}&redirect=&LoginFromWeb=1
|
||||
```
|
||||
|
||||
Form fields:
|
||||
|
||||
| Field | Required | Description |
|
||||
| --- | --- | --- |
|
||||
| `username` | Yes | TCI portal username. |
|
||||
| `password` | Yes | TCI portal password. |
|
||||
| `captcha` | Yes | Text from the captcha image downloaded in the same session. |
|
||||
| `redirect` | Yes | Usually submitted as an empty string. |
|
||||
| `LoginFromWeb` | Yes | Web login flag. Known working value: `1`. Some portal responses may also accept an empty value. |
|
||||
|
||||
Clients should URL-encode all form values.
|
||||
|
||||
Expected result:
|
||||
|
||||
- On success, the response or the redirected page contains an authenticated marker such as `logout` or `خروج`.
|
||||
- On failure, the response remains on or returns to the login page.
|
||||
|
||||
After successful login, save the cookies returned by the login response. These cookies authenticate later requests.
|
||||
|
||||
## Authenticated Panel
|
||||
|
||||
### Fetch Panel
|
||||
|
||||
```http
|
||||
GET /panel HTTP/1.1
|
||||
Host: internet.tci.ir
|
||||
Cookie: ...
|
||||
```
|
||||
|
||||
Purpose:
|
||||
|
||||
- Returns the authenticated user dashboard as HTML.
|
||||
- Contains account and service information, including reserved traffic.
|
||||
|
||||
There is no known structured JSON response for this data in the observed workflow. Clients must parse the returned HTML.
|
||||
|
||||
## Reserved Traffic Extraction
|
||||
|
||||
The reserved traffic value can be extracted from the authenticated `/panel` HTML.
|
||||
|
||||
Known Persian label:
|
||||
|
||||
```text
|
||||
میزان ترافیک رزرو شما
|
||||
```
|
||||
|
||||
Observed extraction strategy:
|
||||
|
||||
1. Search the HTML for an `h5` element containing `میزان ترافیک رزرو شما`.
|
||||
2. Strip HTML tags.
|
||||
3. Normalize whitespace.
|
||||
4. Convert Persian digits to ASCII digits.
|
||||
5. Normalize units:
|
||||
- `گیگابایت` to `GB`
|
||||
- `مگابایت` to `MB`
|
||||
6. Read the final numeric value and unit.
|
||||
|
||||
Example normalized output:
|
||||
|
||||
```text
|
||||
12.5 GB
|
||||
```
|
||||
|
||||
Because the portal returns HTML, clients should treat this parser as fragile and keep it isolated so it can be updated if the page layout changes.
|
||||
|
||||
## Cookie Persistence Format
|
||||
|
||||
Cookie storage is client-specific. A portable representation is a map of cookie names to cookie values for the `internet.tci.ir` domain:
|
||||
|
||||
```json
|
||||
{
|
||||
"cookie_name": "cookie_value"
|
||||
}
|
||||
```
|
||||
|
||||
When restoring persisted cookies, send them to:
|
||||
|
||||
```text
|
||||
Domain: internet.tci.ir
|
||||
Path: /
|
||||
Secure: false or as originally received
|
||||
Expires: session or original expiry
|
||||
```
|
||||
|
||||
For best compatibility, preserve all cookie attributes if your HTTP library exposes them.
|
||||
|
||||
## Error Handling
|
||||
|
||||
Recommended client behavior:
|
||||
|
||||
- If `GET /panel` fails with a network or TLS error, report the request failure.
|
||||
- If the login page does not contain a form action, treat the portal HTML as changed.
|
||||
- If the login page does not contain `#loginCaptchaImage`, treat the portal HTML as changed.
|
||||
- If captcha download fails, restart the login flow from `GET /panel`.
|
||||
- If login POST does not return an authenticated marker, ask for a new captcha or verify credentials.
|
||||
- If an authenticated request returns a login page, clear or refresh cookies and login again.
|
||||
|
||||
## Minimal Client Algorithm
|
||||
|
||||
```text
|
||||
1. Create an HTTP client with cookie storage.
|
||||
2. Load previously saved cookies, if available.
|
||||
3. GET https://internet.tci.ir/panel.
|
||||
4. If response contains "logout" or "خروج":
|
||||
- Session is valid.
|
||||
- Continue to panel parsing.
|
||||
5. Otherwise:
|
||||
- Parse login form action.
|
||||
- Parse captcha image URL from #loginCaptchaImage.
|
||||
- GET captcha image using the same cookies.
|
||||
- Solve captcha.
|
||||
- POST credentials, captcha, redirect="", LoginFromWeb=1 to the form action.
|
||||
- Verify authenticated marker in the response.
|
||||
- Save cookies.
|
||||
6. GET https://internet.tci.ir/panel.
|
||||
7. Parse required dashboard values from HTML.
|
||||
```
|
||||
|
||||
## Example cURL Flow
|
||||
|
||||
```bash
|
||||
BASE_URL="https://internet.tci.ir"
|
||||
COOKIE_JAR="./cookies.txt"
|
||||
|
||||
# 1. Fetch login page or authenticated panel.
|
||||
curl -fsSL --compressed -L \
|
||||
-b "$COOKIE_JAR" \
|
||||
-c "$COOKIE_JAR" \
|
||||
"$BASE_URL/panel" \
|
||||
-o login.html
|
||||
|
||||
# 2. Parse login form action and captcha URL from login.html.
|
||||
# The exact parser is implementation-specific.
|
||||
|
||||
# 3. Download captcha with the same cookies.
|
||||
curl -fsSL --compressed -L \
|
||||
-b "$COOKIE_JAR" \
|
||||
-c "$COOKIE_JAR" \
|
||||
"$CAPTCHA_URL" \
|
||||
-o captcha.jpg
|
||||
|
||||
# 4. Submit login.
|
||||
curl -fsSL --compressed -L \
|
||||
-b "$COOKIE_JAR" \
|
||||
-c "$COOKIE_JAR" \
|
||||
--data-urlencode "username=$TCI_USERNAME" \
|
||||
--data-urlencode "password=$TCI_PASSWORD" \
|
||||
--data-urlencode "captcha=$CAPTCHA_TEXT" \
|
||||
--data-urlencode "redirect=" \
|
||||
--data-urlencode "LoginFromWeb=1" \
|
||||
"$LOGIN_ACTION_URL" \
|
||||
-o panel.html
|
||||
|
||||
# 5. Fetch authenticated panel again if needed.
|
||||
curl -fsSL --compressed -L \
|
||||
-b "$COOKIE_JAR" \
|
||||
-c "$COOKIE_JAR" \
|
||||
"$BASE_URL/panel" \
|
||||
-o panel.html
|
||||
```
|
||||
|
||||
## Security Notes
|
||||
|
||||
- Store usernames, passwords, and cookies securely.
|
||||
- Treat cookies as credentials.
|
||||
- Do not log passwords, captcha text, or full cookie values.
|
||||
- Use HTTPS only.
|
||||
- Do not share persisted session cookies between users.
|
||||
|
||||
## Known Limitations
|
||||
|
||||
- The portal uses HTML pages rather than stable JSON endpoints.
|
||||
- Captcha is mandatory in the observed login flow.
|
||||
- Page structure and Persian labels may change without versioning. (But nothing has changed over the past decade.)
|
||||
- The reserved traffic parser depends on current dashboard markup.
|
||||
Reference in new issue
Block a user