### jQuery authByLogin Implementation Source: https://freedom24.com/tradernet-api An example of performing the authByLogin request using the jQuery library. ```javascript /** * @type {authByLogin} */ var exampleParams = { "cmd": "authByLogin", "params": { "login": "user@example.com", "password": "password", "rememberMe": 1, "getAccounts": false, "userId": 1234 }, }; function authByLogin(callback) { $.post("https://tradernet.com/api/", {q: JSON.stringify(exampleParams)}, callback); } /** * Get the object **/ authByLogin(function(json){ console.log(json); }); ``` -------------------------------- ### Successful Authentication Response Source: https://freedom24.com/tradernet-api The JSON response returned upon successful authentication, containing the session ID (SID) and user account details. ```json { "success": true, "logged": true, "SID": "skjdhfahdf2847928743kjsfhd", "isSecuritySessionOpened": false, "userId": 1234, "real": true, "account_type": "brokerage", "account_title": "Trading account", "reception_country": "EU", "reception_code": "EU", "reception_name": "EU", "reception_title": "Freedom Finance", "reception_type": "broker", "hasAdminPanel": true } ``` -------------------------------- ### POST /api/ authByLogin Source: https://freedom24.com/tradernet-api Authenticates a user using a login and password combination. Returns a session ID and user details upon success, or an error object on failure. ```APIDOC ## POST /api/ authByLogin ### Description Authenticates a user using a login and password combination. Returns a session ID and user details upon success, or an error object on failure. ### Method POST ### Endpoint https://tradernet.com/api/ ### Parameters #### Request Body - **cmd** (string) - Required - Request execution command, set to "authByLogin". - **params** (array) - Required - Request execution parameters. - **login** (string) - Required - User login. - **password** (string) - Required - User password. - **rememberMe** (integer) - Optional - Remember the session for 2 weeks. - **getAccounts** (boolean) - Optional - List all accounts associated with this login. - **viewOnlyMode** (boolean) - Optional - Account access is limited to view-only mode. - **userId** (integer) - Optional - Specify a specific User ID for authorization. ### Request Example { "cmd": "authByLogin", "params": { "login": "user@example.com", "password": "password", "rememberMe": 1, "getAccounts": false, "userId": 1234 } } ### Response #### Success Response (200) - **success** (boolean) - Indicates the request was successful. - **logged** (boolean) - Indicates the user is logged in. - **SID** (string) - Session ID. - **isSecuritySessionOpened** (boolean) - Whether a security session is opened. - **userId** (integer) - User ID. - **real** (boolean) - Whether the account is real. - **account_type** (string) - Account type. - **account_title** (string) - Account title. - **reception_country** (string) - Reception country. - **reception_code** (string) - Reception code. - **reception_name** (string) - Reception name. - **reception_title** (string) - Reception title. - **reception_type** (string) - Reception type. - **hasAdminPanel** (boolean) - Whether the user has admin panel access. #### Response Example { "success": true, "logged": true, "SID": "skjdhfahdf2847928743kjsfhd", "isSecuritySessionOpened": false, "userId": 1234, "real": true, "account_type": "brokerage", "account_title": "Trading account", "reception_country": "EU", "reception_code": "EU", "reception_name": "EU", "reception_title": "Freedom Finance", "reception_type": "broker", "hasAdminPanel": true } #### Error Response - **errMsg** (string) - Error message. - **code** (integer) - Error code. #### Error Example { "errMsg": "Bad json", "code": 2 } ### Usage Example (JavaScript with jQuery) ```javascript /** * @type {authByLogin} */ var exampleParams = { "cmd": "authByLogin", "params": { "login": "user@example.com", "password": "password", "rememberMe": 1, "getAccounts": false, "userId": 1234 }, }; function authByLogin(callback) { $.post("https://tradernet.com/api/", {q: JSON.stringify(exampleParams)}, callback); } /** * Get the object **/ authByLogin(function(json){ console.log(json); }); ``` ``` -------------------------------- ### HTTPS POST authByLogin Request Source: https://freedom24.com/tradernet-api The JSON structure for the authByLogin command. Parameters include login, password, and optional fields like rememberMe and userId. ```json { "cmd" (string) : "authByLogin", "params" (array) : { "login" (string): "user@example.com", "password" (string): "password", "rememberMe" (integer|null): 1, "getAccounts" (boolean|null): false, "userId" (integer|null): 1234 }, } ``` -------------------------------- ### Authentication Error Response Source: https://freedom24.com/tradernet-api The JSON structure returned when an authentication request fails, providing an error message and code. ```json // Common error { "errMsg" : "Bad json", "code" : 2 } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.