Constructor
new TeraBoxApp(authData, authTypeopt)
Properties:
| Name | Type | Description | |||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
FormUrlEncoded |
FormUrlEncoded | Form URL encoding utility | |||||||||||||||||||||
SignDownload |
signDownload | Download signature generator | |||||||||||||||||||||
CheckMd5Val |
checkMd5val | MD5 hash validator (single) | |||||||||||||||||||||
CheckMd5Arr |
checkMd5arr | MD5 hash validator (array) | |||||||||||||||||||||
DecodeMd5 |
decodeMd5 | Custom MD5 transformation | |||||||||||||||||||||
ChangeBase64Type |
changeBase64Type | Base64 format converter | |||||||||||||||||||||
DecryptAES |
decryptAES | AES decryption utility | |||||||||||||||||||||
EncryptRSA |
encryptRSA | RSA encryption utility | |||||||||||||||||||||
PRandGen |
prandGen | Pseudo-random hash generator | |||||||||||||||||||||
TERABOX_DOMAIN |
string | Default TeraBox domain | |||||||||||||||||||||
TERABOX_TIMEOUT |
number | Default API timeout (10 seconds) | |||||||||||||||||||||
data |
Object | Application data including tokens and keys
Properties
|
|||||||||||||||||||||
params |
TeraBoxAppParams | Application parameters and configuration |
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
authData |
string | Authentication data (NDUS token) | ||
authType |
string |
<optional> |
'ndus'
|
Authentication type (currently only 'ndus' supported) |
Throws:
-
Throws error if authType is not supported
- Type
- Error
Methods
(async) updateAppData(customPathopt, retriesopt) → {Promise.<Object>}
- Description:
- Updates application data including tokens and user information
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
customPath |
string |
<optional> |
Custom path to use for the update request | |
retries |
number |
<optional> |
4
|
Number of retry attempts |
Throws:
-
Throws error if request fails or parsing fails
- Type
- Error
Returns:
The updated template data
- Type
- Promise.<Object>
setVipDefaults() → {void}
Returns:
- Type
- void
(async) doReq(req_url, req_optionsopt, retriesopt) → {Promise.<Object>}
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
req_url |
string | The request URL (relative to whost) | ||
req_options |
Object |
<optional> |
{}
|
Request options (headers, body, etc.) |
retries |
number |
<optional> |
4
|
Number of retry attempts |
Throws:
-
Throws error if all retries fail
- Type
- Error
Returns:
The JSON-parsed response data
- Type
- Promise.<Object>
(async) getSysCfg() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The system configuration JSON data
- Type
- Promise.<Object>
(async) checkLogin() → {Promise.<CheckLoginResponse>}
Throws:
-
Throws error if HTTP status is not 200 or request fails.
- Type
- Error
Returns:
The login status JSON data.
- Type
- Promise.<CheckLoginResponse>
(async) passportPreLogin(email) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
email |
string | The user's email address |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The pre-login data JSON (includes seval, random, timestamp)
- Type
- Promise.<Object>
(async) passportLogin(preLoginData, email, pass) → {Promise.<Object>}
- Description:
- Completes the passport login process using preLoginData and password
- Source:
Parameters:
| Name | Type | Description | ||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
preLoginData |
Object | Data returned from passportPreLogin
Properties
|
||||||||||||
email |
string | The user's email address | ||||||||||||
pass |
string | The user's plaintext password |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The login response JSON (includes ndus token on success)
- Type
- Promise.<Object>
(async) regSendCode(email) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
email |
string | The email address to send the code to |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The send code response JSON (includes code and message)
- Type
- Promise.<Object>
(async) regVerify(regToken, code) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
regToken |
string | Registration token from send code response |
code |
string | number | The verification code sent to email |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The verification response JSON
- Type
- Promise.<Object>
(async) regFinish(regToken, pass) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
regToken |
string | Registration token from verification step |
pass |
string | The new password to set, length is 6-15 and contains at least 1 Latin letter |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The finish registration response JSON (includes ndus token on success)
- Type
- Promise.<Object>
(async) passportGetInfo() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The passport user info JSON (includes display_name)
- Type
- Promise.<Object>
(async) userMembership() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The membership JSON (includes VIP status)
- Type
- Promise.<Object>
(async) getCurrentUserInfo() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The user info JSON (includes records array)
- Type
- Promise.<Object>
(async) getUserInfo(user_id) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
user_id |
number | string | The user ID to look up |
Throws:
-
Throws error if user_id is invalid, HTTP status is not 200, or request fails
- Type
- Error
Returns:
The user info JSON (includes data)
- Type
- Promise.<Object>
(async) getQuota() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The quota JSON (includes total, used, available)
- Type
- Promise.<Object>
(async) setUserBirthday(birthday, is_adult) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
birthday |
string | User Birthday in YYYY-MM-DD format |
is_adult |
number | string | Is User adult status (0 or 1) |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
Status JSON
- Type
- Promise.<Object>
(async) getCoinsCount() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The coins count JSON (includes records of coin usage)
- Type
- Promise.<Object>
(async) getRemoteDir(remoteDir, pageopt) → {Promise.<Object>}
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
remoteDir |
string | Remote directory path to list | ||
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The directory listing JSON (includes entries array)
- Type
- Promise.<Object>
(async) search(term, pageopt) → {Promise.<Object>}
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
term |
string | term to search | ||
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The file listing JSON (includes entries array)
- Type
- Promise.<Object>
(async) getCategoryList(categoryIdopt, remoteDir, pageopt) → {Promise.<Object>}
- Description:
- Retrieves the contents of a remote directory with specific file category
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
categoryId |
number |
<optional> |
1
|
selected category:
1: video 2: audio 3: pictures 4: documents 5: apps (not working?) 6: other 7: torrent (now included in category 6, not working) |
remoteDir |
string |
/
|
Remote directory path to list | |
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The directory listing JSON (includes entries array)
- Type
- Promise.<Object>
(async) getRecycleBin() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The recycle bin listing JSON (includes entries array)
- Type
- Promise.<Object>
(async) clearRecycleBin() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The clear recycle bin response JSON
- Type
- Promise.<Object>
(async) precreateFile(data) → {Promise.<Object>}
- Description:
- Initiates a precreate request for a file (reserve upload ID and pre-upload checks)
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | File data including remote_dir, file, size, upload_id (optional), and hash info
Properties
|
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The precreate response JSON (includes upload_id, etc.)
- Type
- Promise.<Object>
(async) rapidUpload(data) → {Promise.<Object>}
- Description:
- Attempts a rapid upload using existing file hashes (skip actual upload if file already on server)
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | File data including remote_dir, file, size, and hash info
Properties
|
Throws:
-
Throws error if file size < 256KB, invalid hashes, HTTP status is not 200, or request fails
- Type
- Error
Returns:
The rapid upload response JSON (indicates success or fallback)
- Type
- Promise.<Object>
(async) remoteUpload(urls, remote_dir) → {Promise.<Object>}
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
urls |
string | Source urls (coma-separated) | |
remote_dir |
string |
/Remote Upload
|
Remote directory path |
Throws:
-
Throws error if HTTP status is not 200, or request fails
- Type
- Error
Returns:
The remote upload response JSON (indicates success or fallback)
- Type
- Promise.<Object>
(async) remoteUploadList(page, page_size, order_by, order) → {Promise.<Object>}
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
page |
string |
1
|
page number |
page_size |
string |
20
|
items per page |
order_by |
string |
ctime
|
sort by field, for example "ctime" |
order |
string |
desc
|
asc or desc |
Throws:
-
Throws error if HTTP status is not 200, or request fails
- Type
- Error
Returns:
Response JSON (indicates success or fallback)
- Type
- Promise.<Object>
(async) remoteUploadDelete(task_id) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
task_id |
string | task id to remove |
Throws:
-
Throws error if HTTP status is not 200, or request fails
- Type
- Error
Returns:
Response JSON (indicates success or fallback)
- Type
- Promise.<Object>
(async) clouddl_tasklist(start, limit, status) → {Promise.<Object>}
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
start |
string |
0
|
task list offset |
limit |
string |
20
|
tasks per page |
status |
string |
255
|
list tasks status filter,
0: Download successful 1: Download in progress 2: System error 3: The resource does not exist 4: Download timeout 5: The resource exists but the download failed 6: Insufficient storage space 7: The target address data already exists 8: Task canceled 255: All tasks |
Throws:
-
Throws error if HTTP status is not 200, or request fails
- Type
- Error
Returns:
Cloud_DL service task list JSON
- Type
- Promise.<Object>
(async) clouddl_query_task(op_type, task_ids) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
op_type |
string | Operation type; 0: Check task information, 1: Check progress information |
task_ids |
string | Task ID info (comma-separated) |
Throws:
-
Throws error if HTTP status is not 200/403, or request fails
- Type
- Error
Returns:
Cloud_DL service task info JSON
- Type
- Promise.<Object>
(async) clouddl_add_task(source, sha1hash, save_path, selected_idx) → {Promise.<Object>}
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
source |
string | remote torrent file path, ed2k, magnet or https link | |
sha1hash |
string | torrent hash (fetch it from clouddl_query_sinfo), required for torrent | |
save_path |
string |
/Remote Upload
|
remote save path (directory) |
selected_idx |
string | select file indexes from torrent file / magnet (comma-separated with starting index 1) |
Throws:
-
Throws error if HTTP status is not 200/400/403/405/500, or request fails
- Type
- Error
Returns:
Cloud_DL service task info JSON
- Type
- Promise.<Object>
(async) clouddl_cancel_task(task_id) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
task_id |
string | Task to cancel by id |
Throws:
-
Throws error if HTTP status is not 200/400/404/409, or request fails
- Type
- Error
Returns:
Cloud_DL service task info JSON
- Type
- Promise.<Object>
(async) clouddl_delete_task(task_id) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
task_id |
string | Task to delete by id |
Throws:
-
Throws error if HTTP status is not 200/400/403/404, or request fails
- Type
- Error
Returns:
Cloud_DL service task info JSON
- Type
- Promise.<Object>
(async) clouddl_query_sinfo(source_path) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
source_path |
string | file path to the torrent file on TB drive |
Throws:
-
Throws error if HTTP status is not 200/400/403/404/500, or request fails
- Type
- Error
Returns:
Cloud_DL torrent file info JSON
- Type
- Promise.<Object>
(async) clouddl_query_magnetinfo(magnet_link) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
magnet_link |
string | magnet link url |
Throws:
-
Throws error if HTTP status is not 200/403, or request fails
- Type
- Error
Returns:
Cloud_DL magnet link info JSON
- Type
- Promise.<Object>
(async) getUploadHost() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The upload host response JSON (includes host field)
- Type
- Promise.<Object>
(async) uploadChunk(data, partseq, blob, reqHandleropt, externalAbortopt) → {Promise.<Object>}
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
data |
Object | File data including remote_dir, file, upload_id | |
partseq |
number | The sequence number of this chunk (0-based) | |
blob |
Blob | Buffer | The binary data of the chunk | |
reqHandler |
function |
<optional> |
Optional request progress handler |
externalAbort |
AbortSignal |
<optional> |
Optional external abort signal |
Throws:
-
Throws error if HTTP status is not 200, chunk upload fails, or request times out
- Type
- Error
Returns:
The upload chunk response JSON (includes MD5 for chunk)
- Type
- Promise.<Object>
(async) createDir(remoteDir) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
remoteDir |
string | The path of the directory to create |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The create directory response JSON
- Type
- Promise.<Object>
(async) createFile(data) → {Promise.<Object>}
- Description:
- Creates a new file entry on the server after uploading chunks
- Source:
Parameters:
| Name | Type | Description | |||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
data |
Object | File data including remote_dir, file, size, hash, upload_id, and chunks
Properties
|
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The create file response JSON (includes MD5 and ETag)
- Type
- Promise.<Object>
(async) filemanager(operation, fmparams) → {Promise.<Object>}
- Description:
- Performs file management operations (delete, copy, move, rename)
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
operation |
string | Operation type: 'delete', 'copy', 'move', 'rename' |
fmparams |
Array | Parameters for the operation (array of paths or objects) |
Throws:
-
Throws error if fmparams is not an array, HTTP status is not 200, or request fails
- Type
- Error
Returns:
The file manager response JSON
- Type
- Promise.<Object>
(async) shareList() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The share list JSON (includes share entries)
- Type
- Promise.<Object>
(async) shareSet(filelist, passopt, periodopt) → {Promise.<Object>}
- Description:
- Sets sharing parameters (e.g., password, expiration) for specified files
- Source:
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
filelist |
Array.<string> | Array of file paths to share | ||
pass |
string |
<optional> |
''
|
Optional 4-character alphanumeric password |
period |
number |
<optional> |
0
|
Sharing period in days (0 for no expiration) |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The share set response JSON (includes share IDs)
- Type
- Promise.<Object>
(async) shareCancel(shareid_listopt) → {Promise.<Object>}
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
shareid_list |
Array.<number> |
<optional> |
[]
|
Array of share IDs to cancel |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The share cancel response JSON
- Type
- Promise.<Object>
(async) shortUrlInfo(shortUrl) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
shortUrl |
string | The short url: after "surl=" |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The short URL info JSON (includes file list, permissions)
- Type
- Promise.<Object>
(async) shortUrlList(shortUrl, remoteDiropt, pageopt) → {Promise.<Object>}
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
shortUrl |
string | The short url: after "surl=" | ||
remoteDir |
string |
<optional> |
''
|
Remote directory under share (empty for root) |
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The short URL file list JSON (includes entries array)
- Type
- Promise.<Object>
(async) fileDiff() → {Promise.<Object>}
- Description:
- Retrieves file difference (delta) information for synchronization
- Source:
Throws:
-
Throws error if HTTP status is not 200, request fails, or on recursive errors
- Type
- Error
Returns:
The file diff JSON (includes entries, request_id, has_more flag)
- Type
- Promise.<Object>
(async) genPanToken() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The PAN token response JSON (includes pan token and expire)
- Type
- Promise.<Object>
(async) getHomeInfo() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The home info JSON (includes sign1, sign3, data.signb)
- Type
- Promise.<Object>
(async) download(fs_ids, signb) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
fs_ids |
Array.<number> | Array of file system IDs to download |
signb |
string | Base64-encoded signature from getHomeInfo |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The download response JSON (includes dlink URLs)
- Type
- Promise.<Object>
(async) getStream(remotePath, type) → {Promise.<Object>}
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
remotePath |
string |
/video.mp4
|
Remote video file |
type |
string |
M3U8_AUTO_480
|
Streaming type:
M3U8_FLV_264_480 M3U8_AUTO_240 M3U8_AUTO_360 M3U8_AUTO_480 M3U8_AUTO_720 M3U8_AUTO_1080 M3U8_SUBTITLE_SRT |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
m3u8 playlist, or JSON with error
- Type
- Promise.<Object>
(async) getFileMeta(remote_file_list) → {Promise.<Object>}
Parameters:
| Name | Type | Description |
|---|---|---|
remote_file_list |
Array.<Object> | Array of file descriptor objects { fs_id, path, etc. } |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The file metadata JSON (includes size, md5, etc.)
- Type
- Promise.<Object>
(async) getRecentUploads(pageopt) → {Promise.<Object>}
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
page |
number |
<optional> |
1
|
Page number for pagination |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The recent uploads JSON (includes records array)
- Type
- Promise.<Object>
(async) querySurlTransfer(shareId, fromUk) → {Promise.<Object>}
- Description:
- Queries transfer information for a shared URL
Used to check if shared files can be transferred to the user's account
before performing the actual transfer operation.
- Queries transfer information for a shared URL
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
shareId |
number | The share ID from shortUrlList response |
fromUk |
number | The owner user ID (uk) from shortUrlList response |
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The query transfer response JSON
- Type
- Promise.<Object>
(async) shareTransfer(shareId, fromUk, fsIds, destPathopt, optionsopt) → {Promise.<Object>}
- Description:
- Transfers (saves) shared files to the user's account
This method saves files from a shared link to the user's own TeraBox storage.
The files will be copied to the specified destination path.
- Transfers (saves) shared files to the user's account
- Source:
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
shareId |
number | The share ID of the shared content | ||||||||||||
fromUk |
number | The user ID (uk) of the share owner | ||||||||||||
fsIds |
Array.<number> | Array of file system IDs to transfer | ||||||||||||
destPath |
string |
<optional> |
'/'
|
Destination path in user's storage | ||||||||||
options |
Object |
<optional> |
{}
|
Optional parameters
Properties
|
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The transfer response JSON (includes task_id on success)
- Type
- Promise.<Object>
(async) getPublicKey() → {Promise.<Object>}
Throws:
-
Throws error if HTTP status is not 200 or request fails
- Type
- Error
Returns:
The public key response JSON (includes pp1 and pp2)
- Type
- Promise.<Object>