--- title: Internet Banking API - HCMUS --- # **APIs** ---- ### **/api/v1/accounts** <_Get information with account number_> ```c POST /api/v1/accounts HTTP/1.1 x-api-key: O8DGCVLGAYG7YLHBHJF9VQ x-time-code: 1581617456 Content-Length: 1181 Host: localhost:8080 Content-Type: application/json { "content": { "account": "12000323012" }, "hash": "$2a$09$ZtS7uXfPMRfRUblK7dEOG.unmlYRKDl75fSLmXOFIF2dMUaL71bom" } ``` ```c HTTP/1.1 200 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Thu, 13 Feb 2020 06:20:26 GMT { "data": { "account": "12000323012", "name": "Nguyễn Minh Anh", "bank": "HCB_BANK" }, "sign": "mt85eITgWg6SlMe+srCPfwLuAdMhIO2NXONyUDJXEpO/r4zlsBDov2LATazh//yp922+lTMMV2QOcMfH/q6bpHvteGpgYfbe5P75jfpm09YUmW+NpxQD3QNanvLZPfcPHJTW0xU5dJWHSL6bGLk6Xc76Sg+SOYT8qD4Sm3lWbbD4xRmrp9j4de/D5C7BL9b5ZLP8gpR3LivLVBLOGZ+jzBpmCLO0X1YvvbyxEiKqpSWw8h53SOx5TL49ySmvrNmZONCXT8hftQJPDhEaUb+gSEG1Pbord5xRI/1eKMETFhL6IX1eusyiBBSjijO56cYnq9fjT1qeWyH2VRRZU7QjZw==" } ``` ### **/api/v1/transactions** <_Transactions_> * `Amount > 0: ` <_Pay into `account`_> * `Amount < 0: ` <_Withdraw from `account`_> ```c POST /api/v1/transactions HTTP/1.1 x-api-key: O8DGCVLGAYG7YLHBHJF9VQ x-time-code: 1581617456 Content-Length: 1181 Host: localhost:8080 Content-Type: application/json { "content": { "account": "120010000042", "amount": -3000000, "content": "TT nợ" }, "sign": "cuwDjqZCssHOAswqzwS7Y1epxmNCggyAW7xsZU0rQfv5INAOSVRwN1fcD0bKXeRIlmsrG8OpqHkVeeL4IepILEtDjg5oHKhJj66RgO3SU6671mmfqIi1qUKXU4ewQVI5Ha44AQqLovY6Aub7027MogsnYtrTqBenfNLQhXHOgBhNHrsLFifh6Dq0SpzCyL7stw5WIouGjsnJ6dDRNYLHKdr77fT6STsNHzyaatO4eqBGyLzbiiXIJu39wW9iMXBkmNwMCVik0e9MRKu+2TuL3LmMXDwIvhX4Jk/PRveRJSmJJsUIoyvHKWWkRp8CBM5kwXGcUuykOAPcblowzykjSw==", "hash": "$2a$09$ZtS7uXfPMRfRUblK7dEOG.unmlYRKDl75fSLmXOFIF2dMUaL71bom" } ``` ```c HTTP/1.1 200 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Thu, 16 Feb 2020 09:30:26 GMT { "data": { "account": "120010000042", "amount": -3000000, "content": "TT nợ" }, "sign": "J5HIW8Q5Bi/m9xx1V7Q1msmr0dxAcYONE+hdruZaWLIaAcD4vtahpiJr8QPYxvnW9yFhIamI6i7ipr/7yA4KKK/FK+uUb+KTwCyJB4SLGIC/Ju5EmJagFkfOCmM5U9tZrlQ0PfuP+f+Sdly2PDIJjSM4w2++65nJqfk6dbt5QhdiJdM5B8yyrBvs2UdL2FJowUOqat+HNYjdyTweYdEwkKI/kyThoVWRJYufWpbrMZjmJ1qYxyUx0Fh6lBKkcrFNnIqBfRFsbC2kGXh4C3HyYJvQXrjfEWLETZ2wYy9r8fMASIwkmb4AyJOnM8LrB1Gm8FSJ3MvxPAV5ZZtOmcFsSQ==" } ``` # **API Document** ---- ### **URL:** `/api/v1/**` ### **Method:** `POST` ### **Headers:** `Content-Type: application/json` <br /> `x-api-key: ***` <_API key_> <br /> `x-time-code: ***` <_Expire time `Unix Timestamp`_> ### **Body:** ```c { "content": {}, "sign": "", "hash": "" } ``` * `sign:` <_Base64 encoded signature of `content` request_> * `Private key: ` <_RSA/PGP cryptographic algorithm_> * `Public key: ` <_Give us Base64 encoded string_> * `hash:` <_Hash API key & Expire time with BCrypt Encoder_> ### **Response:** *Code: 200* ```c { "data": {}, "sign": "" } ``` `sign: ` <_Signature of type SHA256withRSA, initialize it with our `private key` generated by RSA algorithm, updated it with all the bytes in `data` response json string. This signature is a Base64 encoded string_> ### **Error Response:** *Code: 401 UNAUTHORIZED* ```c { "timestamp": "2020-01-30T06:44:52.079+0000", "status": 401, "error": "Unauthorized", "message": "Unauthorized", "path": "/api/v1/" } ``` ### **Example:** ```c POST /api/v1/users HTTP/1.1 x-api-key: ABU992AG x-time-code: 9999999999999 Content-Length: 1181 Host: localhost:8080 Content-Type: application/json { "content": { "email": "ngoton.it@gmail.com" }, "sign": "cuwDjqZCssHOAswqzwS7Y1epxmNCggyAW7xsZU0rQfv5INAOSVRwN1fcD0bKXeRIlmsrG8OpqHkVeeL4IepILEtDjg5oHKhJj66RgO3SU6671mmfqIi1qUKXU4ewQVI5Ha44AQqLovY6Aub7027MogsnYtrTqBenfNLQhXHOgBhNHrsLFifh6Dq0SpzCyL7stw5WIouGjsnJ6dDRNYLHKdr77fT6STsNHzyaatO4eqBGyLzbiiXIJu39wW9iMXBkmNwMCVik0e9MRKu+2TuL3LmMXDwIvhX4Jk/PRveRJSmJJsUIoyvHKWWkRp8CBM5kwXGcUuykOAPcblowzykjSw==", "hash": "$2a$10$YhWxpuQChDb3YctEDQRO3Onz9SyBjPtfq8OuzRHRv8ey.vRjLZyWS" } ``` ```c HTTP/1.1 200 X-Content-Type-Options: nosniff X-XSS-Protection: 1; mode=block X-Frame-Options: SAMEORIGIN Content-Type: application/json;charset=UTF-8 Transfer-Encoding: chunked Date: Thu, 30 Jan 2020 06:20:26 GMT { "data": { "content":[ { "email":"ngoton.it@gmail.com" } ] }, "sign": "mt85eITgWg6SlMe+srCPfwLuAdMhIO2NXONyUDJXEpO/r4zlsBDov2LATazh//yp922+lTMMV2QOcMfH/q6bpHvteGpgYfbe5P75jfpm09YUmW+NpxQD3QNanvLZPfcPHJTW0xU5dJWHSL6bGLk6Xc76Sg+SOYT8qD4Sm3lWbbD4xRmrp9j4de/D5C7BL9b5ZLP8gpR3LivLVBLOGZ+jzBpmCLO0X1YvvbyxEiKqpSWw8h53SOx5TL49ySmvrNmZONCXT8hftQJPDhEaUb+gSEG1Pbord5xRI/1eKMETFhL6IX1eusyiBBSjijO56cYnq9fjT1qeWyH2VRRZU7QjZw==" } ```