### Basic API Request Example Source: https://keep2share.github.io/api This example demonstrates how to make a generic API request using cURL. Replace `` with the HTTP method (e.g., GET, POST) and `` with the specific API endpoint you wish to access. ```bash curl -X \ https://keep2share.cc/api/v2/ ``` -------------------------------- ### Keep2shareAPI.php SDK Examples Source: https://keep2share.github.io/api This PHP code demonstrates various functionalities of the Keep2ShareAPI class, including login, getting file lists, uploading, getting URLs, creating folders, and checking balance. ```php login(); /** getFiles **/ $getFiles = $api->getFilesList('/', 10, 0, ['date_created'=>-1], 'files'); /** upload **/ $upload = $api->uploadFile('PATH-TO-LOCAL-FILE'); /** getUrl **/ $getUrl = $api->GetUrl('ID-FILE'); /** createFolder **/ $createFolder = $api->createFolder('Any name'); /** getBalance **/ $getBalance = $api->getBalance(); ``` -------------------------------- ### Get Files List Success Response (200 OK) Source: https://keep2share.github.io/api Example of a successful JSON response for the getFilesList endpoint, containing file details. ```json { "status":"success", "code":200, "files": [ { "id":"4632a04bb0d2b", "name":"test", "is_available":false, "is_folder":false, "date_created":"2019-01-01 00:00:01", "size":1024, "md5":"a457f1dd3623a399d78a9672d225ddd5", "extended_info": { "abuses":[{ "type": "hash", "projects": ["k2s"], "blocked_to": "2020-01-01 00:00:01" }], "storage_object":"available", "size":1024, "date_download_last":"2019-01-01 00:00:01", "downloads":1, "access":"public", "content_type":"text" } } ] } ``` -------------------------------- ### Account Info Request Body Example Source: https://keep2share.github.io/api Example JSON request body for the accountInfo endpoint, containing the authentication token. ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse" } ``` -------------------------------- ### Install jq Package Source: https://keep2share.github.io/api Command to install the jq package, which is required for processing JSON data in the Bash upload script. ```bash sudo apt-get install jq ``` -------------------------------- ### Success Response Example Source: https://keep2share.github.io/api Example of a successful API response, typically returned for valid requests. ```json { "status":"success", "code":200, "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse" } ``` -------------------------------- ### Create File Metadata Success Response Source: https://keep2share.github.io/api Example JSON response for a successful file metadata creation. Returns the provided file details. ```json { "status": "success", "code": 200, "file_id": "96a9d7445484c", "title": "Video file", "studio": "Universal Studio", "categories": ["western", "comedy"], "actresses": ["Ann Taylor", "Jennifer Lawrence"], "description": "Simple video file", "tags": ["video_k2s", "video_k2s_1"] } ``` -------------------------------- ### Bad Request Response Example Source: https://keep2share.github.io/api Example of a 400 Bad Request response, indicating invalid request parameters. ```json { "status":"error", "code":400, "errorCode":2, "message":"Invalid request params" } ``` -------------------------------- ### User Login Request Body Example Source: https://keep2share.github.io/api Example JSON payload for the user login API endpoint, including username and password. ```json { "username":"test", "password":"pass", } ``` -------------------------------- ### POST /getUrl Request Example Source: https://keep2share.github.io/api Use this cURL command to request a download URL for a file. Ensure you have a valid `body.json` file containing the necessary parameters. ```curl curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/getUrl ``` -------------------------------- ### Example Request Body for Update Files Source: https://keep2share.github.io/api This JSON object is an example of a request body for the updateFiles endpoint, including authentication token, file IDs, and new name. ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse", "ids":["83f09624b61db","83f09624b61ds"] "new_name":"test" } ``` -------------------------------- ### Get Files List cURL Request Source: https://keep2share.github.io/api Example cURL command to request a list of files using the getFilesList endpoint. Ensure to provide the request body in a file named body.json. ```curl curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/getFilesList ``` -------------------------------- ### GET /captcha Request Example Source: https://keep2share.github.io/api Use this cURL command to retrieve a CAPTCHA image. Replace `` with the `id` obtained from the `/requestCaptcha` endpoint. ```curl curl -X GET \ https://keep2share.cc/api/v2/captcha?id= ``` -------------------------------- ### POST /requestCaptcha Request Example Source: https://keep2share.github.io/api Use this cURL command to request a CAPTCHA challenge and URL when downloading as a non-authorized user. ```curl curl -X POST \ https://keep2share.cc/api/v2/requestCaptcha ``` -------------------------------- ### POST /getSubscriptions Request Example Source: https://keep2share.github.io/api This cURL command is used to retrieve subscriptions by domain name. It requires authentication via `auth_token` and a `body.json` file. ```curl curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/getSubscriptions ``` -------------------------------- ### File Response Body Example (200 OK) Source: https://keep2share.github.io/api This JSON object details a successful response for a file query, including availability and metadata. ```json { "status": "success", "code": 200, "access": "premium", "isAvailableForFree": false, "is_available": true, "is_folder": false, "name": "test.mp4", "size": 7777777, "date_created": "2019-01-01 00:00:01", "video_info": { "duration": 5392.92, "format": "MPEG-4", "width": 768, "height": 1024, "is_streamable": true } } ``` -------------------------------- ### Example Request Body for Delete Files Source: https://keep2share.github.io/api This JSON object is an example of a request body for the deleteFiles endpoint, including authentication token and file IDs. ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse", "ids":["83f09624b61db","83f09624b61ds"] } ``` -------------------------------- ### Success Response (200 OK) Source: https://keep2share.github.io/api Example of a successful JSON response indicating success and providing an ID. ```json { "status":"success", "code":200, "id":"0632a04bb0d21" } ``` -------------------------------- ### JSON Response for getDomainsList (Success) Source: https://keep2share.github.io/api Example of a successful JSON response for the getDomainsList endpoint. It includes status, code, and a list of available domains. ```json { "status":"success", "code":200, "domains":['k2s.cc'] } ``` -------------------------------- ### Forbidden Response Example Source: https://keep2share.github.io/api Example of a 403 Forbidden response, indicating access denial due to security reasons. ```json { "status":"error", "code":403, "errorCode":77, "message":"Network banned" } ``` -------------------------------- ### Example Success Response for Update Files Source: https://keep2share.github.io/api This JSON represents a successful response from the updateFiles endpoint, detailing the status for each processed file. ```json { "status":"success", "code":200, "files": [ { "id":"0632a04bb0d21", "status":"success", "errors":[] } ] } ``` -------------------------------- ### cURL Request for createFolder Source: https://keep2share.github.io/api Example cURL command to create a new folder via the API, specifying content type and data file. ```bash curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/createFolder ``` -------------------------------- ### Folder Response Body Example (200 OK) Source: https://keep2share.github.io/api This JSON structure represents a successful response for a folder query, detailing its contents and properties. ```json { "status": "success", "code": 200, "files": { "id": "1632a04bb0d2b", "access": "public", "isAvailableForFree": true, "name": "test.mp4", "is_available": true, "is_folder": false, "date_created": "2019-01-01 00:00:01", "size": 1024, "video_info": { "duration": 848.901, "width": 1920, "height": 1080, "format": "MPEG-4", "is_streamable": true } } } ``` -------------------------------- ### 200 OK Response Body for getFilesMeta with items Source: https://keep2share.github.io/api Example JSON response body for a successful (200 OK) getFilesMeta request, including detailed file item information. ```json { "status":"success", "code":200, "items": [ { "file_id": "96a9d7445484c", "title": "Video file", "studio": "Studio", "categories": ["western"], "actresses": ["Jennifer Aniston"], "description": "Simple video file", "tags": ["video_k2s", "video_k2s_1", "video_k2s_2"] } ], "total": 1 } ``` -------------------------------- ### Example Response with File Limit Error Source: https://keep2share.github.io/api This JSON indicates a successful operation but includes an error message related to file limits within a specified folder. ```json { "status":"success", "code":200, "files": [ { "id":"0632a04bb0d21", "status":"success", "errors":["Limit files in specified folder reached"] } ] } ``` -------------------------------- ### JSON Response for getBalance (Success) Source: https://keep2share.github.io/api Example of a successful JSON response for the getBalance endpoint. It includes status, code, and the user's balance. ```json { "status":"success", "code":200, "balance":0.20 } ``` -------------------------------- ### Example Success Response for Delete Files Source: https://keep2share.github.io/api This JSON represents a successful response from the deleteFiles endpoint, indicating the number of files deleted. ```json { "status":"success", "code":200, "deleted":2 } ``` -------------------------------- ### 200 OK Response Body for getFilesMeta Source: https://keep2share.github.io/api Example JSON response body for a successful (200 OK) getFilesMeta request, detailing file metadata. ```json { "status":"success", "code":200, "total":10, "items": [ { "userEmail":"user1@test.test", "domainName":"test.test", "expiresAt":"2021-08-25T15:23:15.000Z", "lastPayment":"2021-08-25T15:23:15.000Z" } ] } ``` -------------------------------- ### Create File Metadata - Not Acceptable Response Source: https://keep2share.github.io/api Example JSON response for a 406 Not Acceptable error during file metadata creation. ```json { "status":"error", "code":406, "errorCode":60, "message":"Error create file meta" } ``` -------------------------------- ### POST /getUrl Request Body Example Source: https://keep2share.github.io/api This JSON object represents the request body for the `/getUrl` endpoint, specifying the file ID. ```json { "file_id":"3fe7f38bba329" } ``` -------------------------------- ### Request Body for getFilesMeta Source: https://keep2share.github.io/api Example JSON request body for the getFilesMeta endpoint, including authentication token and domain name. ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse", "domainName":"test.test", "limit":1 } ``` -------------------------------- ### Get Account Info with Access Token Source: https://keep2share.github.io/api Use this CURL command to retrieve account information by providing a permanent access token. ```bash $ curl -X POST \ -H "Content-type: application/json" \ -d '{"access_token":"yourtoken"}' \ https://keep2share.cc/api/v2/accountInfo ``` -------------------------------- ### cURL Request for getFoldersList Source: https://keep2share.github.io/api Example cURL command to call the getFoldersList API endpoint, including content type and data payload. ```bash curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/getFoldersList ``` -------------------------------- ### Example JSON Response Body for Accepted Request Source: https://keep2share.github.io/api This JSON object indicates a successful acceptance of a request, typically for file operations. ```json { "status":"success", "code":202 } ``` -------------------------------- ### Error Response Example (406 Not Acceptable - File Not Available) Source: https://keep2share.github.io/api This JSON indicates a 'Not Acceptable' error, specifically when a file is not available. ```json { "status":"error", "code":406, "errorCode":20, "message":"File not available" } ``` -------------------------------- ### Request Body for File Upload Source: https://keep2share.github.io/api Example JSON payload for uploading files, including authentication token, days, and usage options. ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse", "days":7, "useExist": true, "autoBuy": true } ``` -------------------------------- ### 404 Not Found Response Body Source: https://keep2share.github.io/api Example JSON response body for a 404 Not Found error, indicating the domain was not found. ```json { "status":"error", "code":400, "message":"Domain not found" } ``` -------------------------------- ### cURL Command for getFilesMeta Source: https://keep2share.github.io/api Example cURL command to make a POST request to the getFilesMeta API endpoint, including headers and data file. ```bash curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/getFilesMeta ``` -------------------------------- ### Account Info Endpoint with JSON Body Source: https://keep2share.github.io/api Example cURL command to retrieve account information, including traffic and subscription details. Requires a JSON request body with an auth_token. ```curl curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/accountInfo ``` -------------------------------- ### Create File Metadata Request Body Source: https://keep2share.github.io/api Example JSON payload for creating file metadata. Includes authentication, file identifier, and optional fields like title, description, studio, categories, actresses, and tags. ```json { "auth_token": "cb9tg4rt9lom9gb5i6tudgqlse", "file_id": "96a9d7445484c", "title": "Video file", "studio": "Universal Studio", "categories": ["western", "comedy"], "actresses": ["Ann Taylor", "Jennifer Lawrence"], "description": "Simple video file", "tags": ["video_k2s", "video_k2s_1"] } ``` -------------------------------- ### Request Body for getFilesMeta with specific parameters Source: https://keep2share.github.io/api Example JSON request body for the getFilesMeta endpoint, specifying file IDs, tags, category, actress, page, and size. ```json { "file_ids": ["96a9d7445484c"], "tag": "video_k2s", "category": "western", "actress": "Jennifer Aniston", "page": 0, "size": 100 } ``` -------------------------------- ### cURL Request for getDomainsList Source: https://keep2share.github.io/api Example cURL command to call the POST /getDomainsList endpoint. It specifies the content type, data payload, and the API endpoint. ```curl curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/getDomainsList ``` -------------------------------- ### Create File Metadata cURL Request Source: https://keep2share.github.io/api Example cURL command to create file metadata. It specifies the POST method, content type, data source, and the API endpoint. ```bash curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/createFileMeta ``` -------------------------------- ### cURL Request for resellerGetCode Source: https://keep2share.github.io/api Example cURL command to call the POST /resellerGetCode endpoint. It includes content type and data payload, specifying the API endpoint. ```curl curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/resellerGetCode ``` -------------------------------- ### Upload File (Bash) Source: https://keep2share.github.io/api This script demonstrates how to upload a file using cURL and jq, first fetching form data and then performing the upload. ```APIDOC ## Upload File (Bash) ### Description This script demonstrates how to upload a file using cURL and jq. It first retrieves necessary form data from the API and then uses that data to upload the specified file. ### Usage 1. Save the script as `upload.sh`. 2. Make it executable: `chmod +x upload.sh`. 3. Run the script: `./upload.sh`. ### Prerequisites - `jq` must be installed (`sudo apt-get install jq`). ``` -------------------------------- ### Example JSON Request Body for File Operation Source: https://keep2share.github.io/api This JSON object represents a typical request body for file operations, including authentication token, file ID, and optional new name. ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse", "id":"83f09624b61db" "new_name":"test" } ``` -------------------------------- ### Get Download URL Source: https://keep2share.github.io/api Retrieves a direct download link for a specified file. Requires file_id and optionally accepts authentication tokens, free download keys, and referrer information. ```APIDOC ## POST /getUrl ### Description This method is for receiving a link to download a file. It requires a `file_id` and can optionally use `auth_token`, `free_download_key`, `captcha_challenge`, `captcha_response`, and `url_referrer`. ### Method POST ### Endpoint https://keep2share.cc/api/v2/getUrl ### Parameters #### Request Body - **file_id** (string) - Required - example: 3fe7f38bba329 - **auth_token** (string) - Optional - example: 3fe7f38bba329asdasasd - **free_download_key** (string) - Optional - example: 3fe7f38bba329 - **captcha_challenge** (string) - Optional - example: 3fe7f38bba329asdasasd - **captcha_response** (string) - Optional - example: 3fe7 - **url_referrer** (string) - Optional - example: http://google.com ### Request Example ```json { "file_id":"3fe7f38bba329" } ``` ### Response #### Success Response (200 OK) - **status** (string) - Required - success - **code** (integer) - Required - 200 - **url** (string) - Required - example: https://prx-214.keep2share.cc/6b50f2add0ba8/... #### Response Example ```json { "status":"success", "code":200, "url":"https://prx-214.keep2share.cc/6b50f2add0ba8/name=sometfile.txt" } ``` #### Error Responses - **400 Bad Request**: Invalid request parameters. - **403 Forbidden**: Not authorized for this action. - **406 Not Acceptable**: Various reasons including download limits, file not found, captcha required, etc. ``` -------------------------------- ### Not Acceptable Response Example Source: https://keep2share.github.io/api Example of a 406 Not Acceptable response, typically requiring reCaptcha verification. ```json { "status":"error", "code":406, "errorCode":33, "message":"Please verify your request via re captcha challenge" } ``` -------------------------------- ### Run Upload Script Source: https://keep2share.github.io/api Command to execute the upload script. ```bash $ ./upload.sh ``` -------------------------------- ### POST /createFileMeta Source: https://keep2share.github.io/api Creates metadata for a file, allowing the setting of a title, description, and tags for the specified file. ```APIDOC ## POST /createFileMeta ### Description Creates metadata for a file. Allows setting a title, description, and tags for the specified file. ### Method POST ### Endpoint https://keep2share.cc/api/v2/createFileMeta ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body ##### application/json - **auth_token** (string) - Required - Authentication token. - **file_id** (string) - Required - The ID of the file to create metadata for. - **title** (string) - Optional - The title for the file. - **description** (string) - Optional - The description for the file. - **studio** (string) - Optional - The studio name associated with the file. - **categories** (array) - Optional - A list of categories for the file (max 50). - **actresses** (array) - Optional - A list of actresses associated with the file (max 50). - **tags** (array) - Optional - A list of tags for the file (max 50). ### Request Example ```json { "auth_token": "cb9tg4rt9lom9gb5i6tudgqlse", "file_id": "96a9d7445484c", "title": "Video file", "studio": "Universal Studio", "categories": ["western", "comedy"], "actresses": ["Ann Taylor", "Jennifer Lawrence"], "description": "Simple video file", "tags": ["video_k2s", "video_k2s_1"] } ``` ### Response #### Success Response (200 OK) - **status** (string) - Indicates success. - **code** (integer) - HTTP status code 200. - **file_id** (string) - The ID of the file. - **title** (string) - The title of the file. - **description** (string) - The description of the file. - **tags** (array) - The tags associated with the file. #### Response Example (200 OK) ```json { "status": "success", "code": 200, "file_id": "96a9d7445484c", "title": "Video file", "studio": "Universal Studio", "categories": ["western", "comedy"], "actresses": ["Ann Taylor", "Jennifer Lawrence"], "description": "Simple video file", "tags": ["video_k2s", "video_k2s_1"] } ``` #### Error Response (400 Bad Request) - **status** (string) - Indicates an error. - **code** (integer) - HTTP status code 400. - **errorCode** (integer) - Specific error code (e.g., 2 for incorrect parameter value). - **message** (string) - Description of the error. #### Error Response (403 Forbidden) - **status** (string) - Indicates an error. - **code** (integer) - HTTP status code 403. - **errorCode** (integer) - Specific error code (e.g., 10 for authorization required). - **message** (string) - Description of the error. #### Error Response (406 Not Acceptable) - **status** (string) - Indicates an error. - **code** (integer) - HTTP status code 406. - **errorCode** (integer) - Specific error code (e.g., 60 for error creating file meta). - **message** (string) - Description of the error. ``` -------------------------------- ### 406 Not Acceptable Response Body Source: https://keep2share.github.io/api Example JSON response body for a 406 Not Acceptable error. ```json { "status":"error", "code":406, "errorCode":null, "message":"" } ``` -------------------------------- ### POST /createFolder Source: https://keep2share.github.io/api Allows the creation of new folders within the user's account. Specifies folder name, parent, and access level. ```APIDOC ## POST /createFolder ### Description This method allows create folders. ### Method POST ### Endpoint https://keep2share.cc/api/v2/createFolder ### Parameters #### Request Body - **auth_token** (string) - Required - example: cb9tg4rt9lom9gb5i6tudgqlse - **name** (string) - Required - example: test - **parent** (string) - Optional - parent_id or set default '/' - **access** (string) - Required - Enum: public, premium - **is_public** (boolean) - Optional - default: false ### Request Example ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse", "name":"test", "parent":"/", "access":"public" } ``` ### Response #### Success Response (201 Created) (Response details not provided in source) ``` -------------------------------- ### Get Subscriptions Source: https://keep2share.github.io/api Retrieves subscription information based on a domain name. This method is secured and requires an `auth_token`. ```APIDOC ## POST /getSubscriptions ### Description This method returns subscriptions by domain name. It is secured and requires an `auth_token`. ### Method POST ### Endpoint https://keep2share.cc/api/v2/getSubscriptions ### Parameters #### Request Body - **auth_token** (string) - Required - example: cb9tg4rt9lom9gb5i6tudgqlse - **domainName** (string) - Required - example: "test.test" - **limit** (integer) - Optional - default 20 - **offset** (integer) - Optional - default 0 ``` -------------------------------- ### Get CAPTCHA Image Source: https://keep2share.github.io/api Retrieves a CAPTCHA image. This method requires a CAPTCHA ID as a query parameter. ```APIDOC ## GET /captcha ### Description This method returns an image with a code. ### Method GET ### Endpoint https://keep2share.cc/api/v2/captcha ### Parameters #### Query Parameters - **id** (string) - Required - example: 3fe7f38bba329 ### Request Example ```bash curl -X GET \ https://keep2share.cc/api/v2/captcha?id= ``` ### Response #### Success Response (200 OK) - Content-Type: image/jpg ``` -------------------------------- ### 200 OK Response for getFoldersList Source: https://keep2share.github.io/api Successful response for getFoldersList, containing lists of folder names, IDs, and parent folder information. ```json { "status":"success", "code":200, "foldersList":['test','simple'], "foldersIds":['5432a01230d2b','1632a04bb0d2a'] } ``` -------------------------------- ### GET /reCaptcha Source: https://keep2share.github.io/api Retrieves an HTML page containing the Google reCAPTCHA. This page is used for user verification. ```APIDOC ## GET /reCaptcha ### Description This method returns an html page with Google captcha. ### Method GET ### Endpoint https://keep2share.cc/api/v2/reCaptcha ### Parameters #### Query Parameters - **id** (string) - Required - example: 3fe7f38bba329 ### Response #### Success Response (200) Returns an HTML page with the Google reCAPTCHA. #### Error Response (400 Bad Request) Returned if the provided `id` is not found. - **status** (string) - error - **code** (integer) - 400 - **message** (string) - example: Id not found #### Response Example (400 Bad Request) ```json { "status":"error", "code":400, "message":"Id not found" } ``` ``` -------------------------------- ### Login with Username and Password (CURL) Source: https://keep2share.github.io/api Authenticate with the API using your username and password via CURL to obtain an auth_token. ```bash $ curl -X POST \ -H "Content-type: application/json" \ -d '{"username":"yourbox@gmail.com","password":"yourpassword"}' \ https://keep2share.cc/api/v2/login ``` -------------------------------- ### 403 Forbidden Response Body for getFilesMeta Source: https://keep2share.github.io/api Example JSON response body for a 403 Forbidden error from the getFilesMeta endpoint. ```json { "status":"error", "code":403, "errorCode":10, "message":"You are not authorized for this action" } ``` -------------------------------- ### Not Acceptable Response (406 Not Acceptable) Source: https://keep2share.github.io/api Example of a JSON response for an unacceptable request, including an error code and message. ```json { "status":"error", "code":406, "errorCode":60, "message":"Error create folder" } ``` -------------------------------- ### Successful Test API Response Source: https://keep2share.github.io/api Example of a successful response from the test API endpoint, confirming operational status. ```json { "status":"success", "code":200, "message":"Test was successful!" } ``` -------------------------------- ### reCaptcha ID Not Found Response Source: https://keep2share.github.io/api Example of a 400 Bad Request response when the provided reCaptcha ID is not found. ```json { "status":"error", "code":400, "message":"Id not found" } ``` -------------------------------- ### Upload File (PHP SDK) Source: https://keep2share.github.io/api Demonstrates uploading a file using the Keep2Share PHP SDK. Requires instantiation of the Keep2ShareAPI class with user credentials. ```APIDOC ## Upload File (PHP SDK) ### Description This example shows how to upload a file using the provided Keep2Share PHP SDK. It involves logging in first and then calling the `uploadFile` method. ### Usage 1. Include the `Keep2ShareAPI.php` file. 2. Instantiate the `Keep2ShareAPI` class with your email and password. 3. Call the `login()` method. 4. If login is successful, call the `uploadFile()` method with the file path. ``` -------------------------------- ### Make Script Executable Source: https://keep2share.github.io/api Command to make the upload script executable. ```bash sudo chmod +x upload.sh ``` -------------------------------- ### Response Body (Success - With Extended Info) Source: https://keep2share.github.io/api This is a successful response from the getFilesInfo endpoint when 'extended_info' is true. It includes comprehensive file details, including video information if applicable. ```json { "code": 200, "files": [ { "access": "public", "created_at": "2022-11-19T12:52:20.000Z", "extended_info": { "access": "public", "content_type": "video/mp4", "date_download_last": "2022-12-17 10:14:11", "size": 479125093, "storage_object": "available", "video_info": { "duration": 1692.473, "format": "MPEG-4", "height": 1080, "is_streamable": true, "width": 1920 } }, "id": "da4a6352cb666", "isAvailableForFree": true, "is_available": true, "is_folder": false, "md5": "6661db843941f4b406e590c21caa9ca1", "name": "Super video.mp4", "parent_id": "6715a7cde4e55", "size": 479125093 } ], "status": "success" } ``` -------------------------------- ### 400 Bad Request Response Body for getFilesMeta Source: https://keep2share.github.io/api Example JSON response body for a 400 Bad Request error from the getFilesMeta endpoint. ```json { "status":"error", "code":400, "errorCode":2, "message":"Invalid request params" } ``` -------------------------------- ### POST /createFileByHash Source: https://keep2share.github.io/api Creates a file using its MD5 hash. If a file with the same hash already exists, this speeds up the upload process. Requires authentication. ```APIDOC ## POST /createFileByHash ### Description This method allows you to create a file based on a hash sum (md5). If our project already has a file with this hash sum (md5). Speeds up the upload time file. ### Method POST ### Endpoint https://keep2share.cc/api/v2/createFileByHash ### Parameters #### Request Body - **auth_token** (string) - Required - example: cb9tg4rt9lom9gb5i6tudgqlse - **hash** (string) - Required - example: 'a457f1dd3623a399d78a9672d225ddd1' - **name** (string) - Required - example: 'test2' - **parent** (string) - Optional - parent_id or set default '/' - **access** (string) - Optional - Enum: public, private, premium ### Request Example ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse", "hash":"a457f1dd3623a399d78a9672d225ddd1", "name":"test2" } ``` ### Response #### Success Response (201) - **status** (string) - success - **code** (integer) - 201 - **id** (string) - example: 0632a04bb0d21 #### Response Example ```json { "status":"success", "code":200, "id":"0632a04bb0d21", "link":"https://k2s.cc/file/0632a04bb0d21" } ``` #### Error Response (400) - **status** (string) - error - **code** (integer) - 400 - **errorCode** (integer) - 2 - Incorrect param value - **message** (string) - Invalid request params #### Error Response (403) - **status** (string) - error - **code** (integer) - 403 - **errorCode** (integer) - 10 - You are need authorized - **message** (string) - You are not authorized for this action ``` -------------------------------- ### cURL Request for getFileStatus Source: https://keep2share.github.io/api Example of how to call the getFileStatus API endpoint using cURL. Ensure to provide the request body in 'body.json'. ```curl curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/getFileStatus ``` -------------------------------- ### cURL Request to Create File by Hash Source: https://keep2share.github.io/api Use this cURL command to create a file using its MD5 hash. This method is faster if the file already exists in the system. Ensure the Content-type is application/json and the body is in @body.json. ```curl curl -X POST \ -H "Content-type: application/json" \ -d @body.json \ https://keep2share.cc/api/v2/createFileByHash ``` -------------------------------- ### Login (using username and password) Source: https://keep2share.github.io/api Authenticates a user using their username and password to obtain an authentication token. ```APIDOC ## POST /login ### Description Authenticates a user using their username and password to obtain an authentication token. ### Method POST ### Endpoint https://keep2share.cc/api/v2/login ### Parameters #### Request Body - **username** (string) - Required - The user's email address. - **password** (string) - Required - The user's password. ### Request Example ```json { "username":"yourbox@gmail.com", "password":"yourpassword" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the success of the operation. - **code** (integer) - The HTTP status code. - **auth_token** (string) - The authentication token for subsequent requests. - **message** (string) - A success message. #### Response Example ```json { "status":"success", "code":200, "auth_token":"flmuf4o3uo59s105546dmvmq60", "message":"success" } ``` ``` -------------------------------- ### Get Download URL (cURL) Source: https://keep2share.github.io/api Retrieves a direct download URL for a given file ID using a POST request to the API. ```APIDOC ## Get Download URL (cURL) ### Description This endpoint allows you to obtain a direct download URL for a specific file using its ID. It requires an authentication token. ### Method POST ### Endpoint `https://keep2share.cc/api/v2/getUrl` ### Parameters #### Request Body - **auth_token** (string) - Required - The authentication token for the user. - **file_id** (string) - Required - The ID of the file to get the download URL for. ``` -------------------------------- ### Request Body for createFolder Source: https://keep2share.github.io/api JSON payload for creating a folder, including authentication token, name, parent directory, and access level. ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse", "name":"test", "parent":"/", "access":"public" } ``` -------------------------------- ### POST /getFoldersList Source: https://keep2share.github.io/api Retrieves a list of user's or partner's folders. This method is secured and requires authentication. ```APIDOC ## POST /getFoldersList ### Description This method returns User's/Partner's list of folders. ### Method POST ### Endpoint https://keep2share.cc/api/v2/getFoldersList ### Parameters #### Request Body - **auth_token** (string) - Required - example: cb9tg4rt9lom9gb5i6tudgqlse - **parent_id** (string) - Optional - get sub folders by folder id ### Request Example ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse" } ``` ### Response #### Success Response (200 OK) - **status** (string) - success - **code** (integer) - 200 - **foldersList** (array) - names in order example: [ '/test', '/simple' ] - **foldersIds** (array) - ids in order example: [ '5432a01230d2b', '1632a04bb0d2a' ] - **parentFoldersList** (array) - parent names in order example: [ '/k2s', '/custom' ] - **parentFoldersIds** (array) - parent ids in order example: [ '6432b01230d2b', '9432d01230d2c' ] #### Response Example ```json { "status":"success", "code":200, "foldersList":['test','simple'], "foldersIds":['5432a01230d2b','1632a04bb0d2a'] } ``` #### Error Response (403 Forbidden) - **status** (string) - error - **code** (integer) - 403 - **errorCode** (integer) - 10 - You are need authorized - **message** (string) - You are not authorized for this action #### Response Example ```json { "status":"error", "code":403, "errorCode":10, "message":"You are not authorized for this action" } ``` ``` -------------------------------- ### Initiate ReCaptcha Authorization (CURL) Source: https://keep2share.github.io/api Request a ReCaptcha challenge from the API. This is the first step for authorization when ReCaptcha is required. ```bash $ curl -X POST -H "Content-type: application/json" \ http://keep2share.cc/api/v2/requestReCaptcha ``` -------------------------------- ### Response Body (Success - Without Extended Info) Source: https://keep2share.github.io/api This is a successful response from the getFilesInfo endpoint when 'extended_info' is false or not provided. It includes basic file details. ```json { "code": 200, "files": [ { "access": "public", "id": "da4a6352cb666", "is_available": true, "is_folder": false, "md5": "6661db843941f4b406e590c21caa9ca1", "name": "Super video.mp4", "size": 479125093 } ], "status": "success" } ``` -------------------------------- ### Example JSON Response for Error Source: https://keep2share.github.io/api This JSON structure represents an error response, indicating issues like rate limits or unavailable nodes. ```json { "status":"error", "code":406, "errorCode":63, "message":"No available nodes" } ``` -------------------------------- ### POST /getFilesList Source: https://keep2share.github.io/api This method allows you to receive a File list by its ID or from the root folder in the user's space. It requires authentication and supports various parameters for filtering and sorting the results. ```APIDOC ## POST /getFilesList ### Description This method allows you to receive File list by its ID or from root folder in user space. ### Method POST ### Endpoint https://keep2share.cc/api/v2/getFilesList ### Parameters #### Query Parameters - **parent** (string) - Optional - default '/' - **limit** (integer) - Optional - total number of files to receive, default 100, max 10000 - **offset** (integer) - Optional - sampling start from N file with current order, default 0 - **sort** (array) - Optional - examples: { name: 1 }, { name: -1 }, { date_created: 1 }, { date_created: -1 } - **only_available** (boolean) - Optional - default false - **extended_info** (boolean) - Optional - default false * abuses * storage_object * size * date_download_last * downloads * access * content_type #### Request Body - **auth_token** (string) - Required - example: cb9tg4rt9lom9gb5i6tudgqlse ### Request Example ```json { "auth_token":"cb9tg4rt9lom9gb5i6tudgqlse" } ``` ### Response #### Success Response (200 OK) - **status** (string) - success - **code** (integer) - 200 - **files** (array) - #### Response Example ```json { "status":"success", "code":200, "files": [ { "id":"4632a04bb0d2b", "name":"test", "is_available":false, "is_folder":false, "date_created":"2019-01-01 00:00:01", "size":1024, "md5":"a457f1dd3623a399d78a9672d225ddd5", "extended_info": { "abuses":[ { "type": "hash", "projects": ["k2s"], "blocked_to": "2020-01-01 00:00:01" } ], "storage_object":"available", "size":1024, "date_download_last":"2019-01-01 00:00:01", "downloads":1, "access":"public", "content_type":"text" } } ] } ``` ### Errors #### 400 Bad Request - **status** (string) - error - **code** (integer) - 400 - **errorCode** (integer) - 3 - Incorrect param value - **message** (string) - Invalid request params #### 403 Forbidden - **status** (string) - error - **code** (integer) - 403 - **errorCode** (integer) - 10 - You are need authorized - **message** (string) - You are not authorized for this action #### 406 Not Acceptable - **status** (string) - error - **code** (integer) - 406 - **errorCode** (integer) - 60 - Error create folder - **message** (string) - Error create folder ``` -------------------------------- ### Get reCaptcha Endpoint Source: https://keep2share.github.io/api Use this cURL command to retrieve the reCaptcha HTML page, requiring a valid ID obtained from the requestReCaptcha endpoint. ```curl curl -X GET \ https://keep2share.cc/api/v2/reCaptcha?id= ``` -------------------------------- ### Upload File using PHP SDK Source: https://keep2share.github.io/api This PHP code snippet demonstrates how to upload a file using the Keep2ShareAPI class. It requires the Keep2ShareAPI.php file and valid credentials. ```php login(); if ($result === true) { $uploadResult = $api->uploadFile('somefile.txt'); var_dump($uploadResult); /* array(5) { ["status"]=> string(7) "success" ["success"]=> bool(true) ["status_code"]=> int(200) ["user_file_id"]=> string(13) "a4b8776255952" ["link"]=> string(32) "http://k2s.cc/file/a4b8776255578" } */ } ``` -------------------------------- ### Example JSON Response for Successful Remote Upload Status Source: https://keep2share.github.io/api This JSON structure provides the status of remote uploads, including progress and file IDs. ```json { "status":"success", "code":200, "uploads":[ { "status":3, "progress":100, "file_id":"27dddcb772fec" } ] } ```