{"activeVersionTag":"latest","latestAvailableVersionTag":"latest","collection":{"info":{"_postman_id":"d98c2fc0-eca9-4a8a-9b3e-17b813f6c7c1","name":"RAPID APIs by Axis Direct","description":"Create Your Own Trading Platform Now\n\n_RAPID_ APIs by Axis Direct offer robust REST APIs that enable you to build your personalized trading terminal and effortlessly execute your strategies. Our APIs grant you unrestricted access to real-time market data, orders, live positions, and a wealth of other features.\n\n## API Keys\n\nAxis Securities will onboard you as a API Client and will provide the `X-API-CLIENT-ID` and `AUTHORIZATION_KEY`.\n\n## Encryption and Decryption\n\nOur APIs are behind encryption, that means you will have to encrypt the request body before sending them. The APIs will return an encrypted response you will have to decrypt the same to get the readable API response.\n\n### Encryption\n\nThere are two methods of encryption used here.\n\n1. AES Encryption - For encrypting the payload sent to the API\n    \n2. RSA Encryption - For encrypting the secret key and public key to give apiEncryptionKey  \n    which goes in the header\n    \n\n#### AES Encryption\n\nEncrypt the payload using the Advanced Encryption Standard (AES) algorithm in Galois/Counter Mode (GCM) mode. It takes the plaintext payload and the `secret_key` as input and\n\nThe function encodes the nonce, tag, and ciphertext as base64 strings before concatenating them into the final encrypted payload. This ensures that the encrypted payload is a valid and printable string.\n\nSample Python Code Snippet:\n\n``` python\ndef encrypt_aes(payload, secret_key):\n    # convert the hex string secret key to bytes\n    secret_key_bytes = secret_key.encode()\n    # create an AES cipher object with GCM mode\n    cipher = AES.new(secret_key_bytes, AES.MODE_GCM)\n    # encrypt the payload\n    ciphertext, tag = cipher.encrypt_and_digest(payload.encode())\n    # encode the nonce, ciphertext, and tag as base64\n    encoded_nonce = base64.b64encode(cipher.nonce).decode()\n    encoded_tag = base64.b64encode(tag).decode()\n    encoded_ciphertext = base64.b64encode(ciphertext).decode()\n    # return the encoded payload\n    return f\"{encoded_nonce}.{encoded_tag}.{encoded_ciphertext}\"\n\n ```\n\n#### **RSA Encryption**\n\nEncrypt the secret key using the RSA (Rivest–Shamir–Adleman) algorithm with Optimal Asymmetric Encryption Padding (OAEP). It takes the `secret_key` and the `public_key` in string format, encrypts the `secret_key`, and returns the encrypted payload as a base64-encoded string.\n\nThe public_key parameter should be in PEM format. If you have the `public_key` in another format, you can convert it to PEM format using the following example.\n\n`public_key_pem = f\"-----BEGIN PUBLIC KEY-----\\n{public_key}\\n-----END PUBLIC KEY-----\"`\n\nSample Python Code Snippet:\n\n``` python\ndef encrypt_rsa(secret_key, public_key):\n    # Converts a public key to PEM format.\n    pem_string = f\"-----BEGIN PUBLIC KEY-----\\n{public_key}\\n-----END PUBLIC KEY-----\"   \n    # load the public key\n    key = RSA.import_key(pem_string)\n    # create an RSA OAEP cipher object\n    cipher = PKCS1_OAEP.new(key, SHA256)\n    # encrypt the payload\n    encrypted_payload = cipher.encrypt(secret_key.encode())\n    # encode the encrypted payload as base64\n    encoded_payload = base64.b64encode(encrypted_payload).decode()\n    return encoded_payload\n\n ```\n\n### Decryption\n\nDecrypt the `encoded_payload` using the Advanced Encryption Standard (AES) algorithm in Galois/Counter Mode (GCM) mode. It takes the `encoded_payload` and the `secret_key` as input, decrypts the payload, and returns the original plaintext data.\n\nSample Python Code Snippet:\n\n``` python\ndef decrypt_data(encoded_payload, secret_key):\n    # convert the hex string secret key to bytes\n    secret_key_bytes = secret_key.encode()\n    # split the encoded payload into the nonce, ciphertext, and tag\n    encoded_nonce, encoded_tag, encoded_ciphertext = encoded_payload.split(\".\")\n    # decode the nonce, ciphertext, and tag from base64\n    nonce = base64.b64decode(encoded_nonce)\n    tag = base64.b64decode(encoded_tag)\n    ciphertext = base64.b64decode(encoded_ciphertext)\n    # create an AES cipher object with GCM mode\n    cipher = AES.new(secret_key_bytes, AES.MODE_GCM, nonce=nonce)\n    # decrypt the payload\n    decrypted_payload = cipher.decrypt_and_verify(ciphertext, tag).decode()\n    return decrypted_payload\n\n ```\n\n## How to generate `secret_key` and `public_key`\n\n### Generate Secret Key\n\nThe secret key is a random sequence of bytes used for cryptographic purposes. The length of the key is 16 bytes, resulting in a 128-bit key, converted to a hexadecimal representation. Below is a sample python code to generate the secret key.\n\nSample Python Code Snippet:\n\n``` python\nimport os\nsecret_key = os.urandom(16)\nsecret_key = secret_key.hex()\nsecret_key\n\n ```\n\n### Generate Public Key\n\nUse the [Handshake API](https://www.postman.com/dark-meteor-728322/workspace/axis-rapid-apis/request/33771924-ff9b749a-cb08-44fa-8381-d6ab6987425b?ctx=documentation) to get the public key.","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","isPublicCollection":false,"owner":"33771924","team":6114085,"collectionId":"d98c2fc0-eca9-4a8a-9b3e-17b813f6c7c1","publishedId":"2sA3BkasEf","public":true,"publicUrl":"https://documenter-api.postman.tech/view/33771924/2sA3BkasEf","privateUrl":"https://go.postman.co/documentation/33771924-d98c2fc0-eca9-4a8a-9b3e-17b813f6c7c1","customColor":{"top-bar":"FFFFFF","right-sidebar":"575757","highlight":"AE275F"},"documentationLayout":"classic-double-column","customisation":{"metaTags":[{"name":"description","value":"RAPID APIs by Axis Direct are trading APIs to place/modify/cancel order, manage orders and positions, view holdings and access real time market data. Elevate your trading experience with Axis Securities Trading APIs."},{"name":"title","value":""}],"appearance":{"default":"system_default","themes":[{"name":"dark","logo":"https://content.pstmn.io/308c3c31-1858-49f4-a7a3-8598d296c5fc/TG9nb19kYXJrLnBuZw==","colors":{"top-bar":"282828","right-sidebar":"575757","highlight":"EB1165"}},{"name":"light","logo":"https://content.pstmn.io/12110ce7-4486-4cf1-a632-3bde4fc6053a/TG9nb19saWdodC5wbmc=","colors":{"top-bar":"FFFFFF","right-sidebar":"575757","highlight":"AE275F"}}]}},"version":"8.11.4","publishDate":"2024-07-26T09:52:53.000Z","activeVersionTag":"latest","documentationTheme":"light","metaTags":{"title":"","description":"RAPID APIs by Axis Direct are trading APIs to place/modify/cancel order, manage orders and positions, view holdings and access real time market data. Elevate your trading experience with Axis Securities Trading APIs."},"logos":{"logoLight":"https://content.pstmn.io/12110ce7-4486-4cf1-a632-3bde4fc6053a/TG9nb19saWdodC5wbmc=","logoDark":"https://content.pstmn.io/308c3c31-1858-49f4-a7a3-8598d296c5fc/TG9nb19kYXJrLnBuZw=="}},"statusCode":200},"environments":[{"name":"Production","id":"5ee5b2eb-0d5b-4805-82ec-54208dcc09e6","owner":"33771924","values":[{"key":"baseURL_custAuth","value":"https://welcome-api.axisdirect.in","enabled":true,"type":"default"},{"key":"baseURL_trading","value":"https://invest-api.axisdirect.in","enabled":true,"type":"default"},{"key":"baseURL_funds","value":"https://funds-api.axisdirect.in","enabled":true,"type":"default"}],"published":true}],"user":{"authenticated":false,"permissions":{"publish":false}},"run":{"button":{"js":"https://run.pstmn.io/button.js","css":"https://run.pstmn.io/button.css"}},"web":"https://www.getpostman.com/","team":{"logo":"https://res.cloudinary.com/postman/image/upload/t_team_logo_pubdoc/v1/team/aeda44f681f1ed250cf1a98b999852a7437fc8148d45c33f758dc66d1c1b6902","favicon":""},"isEnvFetchError":false,"languages":"[{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"HttpClient\"},{\"key\":\"csharp\",\"label\":\"C#\",\"variant\":\"RestSharp\"},{\"key\":\"curl\",\"label\":\"cURL\",\"variant\":\"cURL\"},{\"key\":\"dart\",\"label\":\"Dart\",\"variant\":\"http\"},{\"key\":\"go\",\"label\":\"Go\",\"variant\":\"Native\"},{\"key\":\"http\",\"label\":\"HTTP\",\"variant\":\"HTTP\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"OkHttp\"},{\"key\":\"java\",\"label\":\"Java\",\"variant\":\"Unirest\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"Fetch\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"jQuery\"},{\"key\":\"javascript\",\"label\":\"JavaScript\",\"variant\":\"XHR\"},{\"key\":\"c\",\"label\":\"C\",\"variant\":\"libcurl\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Axios\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Native\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Request\"},{\"key\":\"nodejs\",\"label\":\"NodeJs\",\"variant\":\"Unirest\"},{\"key\":\"objective-c\",\"label\":\"Objective-C\",\"variant\":\"NSURLSession\"},{\"key\":\"ocaml\",\"label\":\"OCaml\",\"variant\":\"Cohttp\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"cURL\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"Guzzle\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"HTTP_Request2\"},{\"key\":\"php\",\"label\":\"PHP\",\"variant\":\"pecl_http\"},{\"key\":\"powershell\",\"label\":\"PowerShell\",\"variant\":\"RestMethod\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"http.client\"},{\"key\":\"python\",\"label\":\"Python\",\"variant\":\"Requests\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"httr\"},{\"key\":\"r\",\"label\":\"R\",\"variant\":\"RCurl\"},{\"key\":\"ruby\",\"label\":\"Ruby\",\"variant\":\"Net::HTTP\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"Httpie\"},{\"key\":\"shell\",\"label\":\"Shell\",\"variant\":\"wget\"},{\"key\":\"swift\",\"label\":\"Swift\",\"variant\":\"URLSession\"}]","languageSettings":[{"key":"csharp","label":"C#","variant":"HttpClient"},{"key":"csharp","label":"C#","variant":"RestSharp"},{"key":"curl","label":"cURL","variant":"cURL"},{"key":"dart","label":"Dart","variant":"http"},{"key":"go","label":"Go","variant":"Native"},{"key":"http","label":"HTTP","variant":"HTTP"},{"key":"java","label":"Java","variant":"OkHttp"},{"key":"java","label":"Java","variant":"Unirest"},{"key":"javascript","label":"JavaScript","variant":"Fetch"},{"key":"javascript","label":"JavaScript","variant":"jQuery"},{"key":"javascript","label":"JavaScript","variant":"XHR"},{"key":"c","label":"C","variant":"libcurl"},{"key":"nodejs","label":"NodeJs","variant":"Axios"},{"key":"nodejs","label":"NodeJs","variant":"Native"},{"key":"nodejs","label":"NodeJs","variant":"Request"},{"key":"nodejs","label":"NodeJs","variant":"Unirest"},{"key":"objective-c","label":"Objective-C","variant":"NSURLSession"},{"key":"ocaml","label":"OCaml","variant":"Cohttp"},{"key":"php","label":"PHP","variant":"cURL"},{"key":"php","label":"PHP","variant":"Guzzle"},{"key":"php","label":"PHP","variant":"HTTP_Request2"},{"key":"php","label":"PHP","variant":"pecl_http"},{"key":"powershell","label":"PowerShell","variant":"RestMethod"},{"key":"python","label":"Python","variant":"http.client"},{"key":"python","label":"Python","variant":"Requests"},{"key":"r","label":"R","variant":"httr"},{"key":"r","label":"R","variant":"RCurl"},{"key":"ruby","label":"Ruby","variant":"Net::HTTP"},{"key":"shell","label":"Shell","variant":"Httpie"},{"key":"shell","label":"Shell","variant":"wget"},{"key":"swift","label":"Swift","variant":"URLSession"}],"languageOptions":[{"label":"C# - HttpClient","value":"csharp - HttpClient - C#"},{"label":"C# - RestSharp","value":"csharp - RestSharp - C#"},{"label":"cURL - cURL","value":"curl - cURL - cURL"},{"label":"Dart - http","value":"dart - http - Dart"},{"label":"Go - Native","value":"go - Native - Go"},{"label":"HTTP - HTTP","value":"http - HTTP - HTTP"},{"label":"Java - OkHttp","value":"java - OkHttp - Java"},{"label":"Java - Unirest","value":"java - Unirest - Java"},{"label":"JavaScript - Fetch","value":"javascript - Fetch - JavaScript"},{"label":"JavaScript - jQuery","value":"javascript - jQuery - JavaScript"},{"label":"JavaScript - XHR","value":"javascript - XHR - JavaScript"},{"label":"C - libcurl","value":"c - libcurl - C"},{"label":"NodeJs - Axios","value":"nodejs - Axios - NodeJs"},{"label":"NodeJs - Native","value":"nodejs - Native - NodeJs"},{"label":"NodeJs - Request","value":"nodejs - Request - NodeJs"},{"label":"NodeJs - Unirest","value":"nodejs - Unirest - NodeJs"},{"label":"Objective-C - NSURLSession","value":"objective-c - NSURLSession - Objective-C"},{"label":"OCaml - Cohttp","value":"ocaml - Cohttp - OCaml"},{"label":"PHP - cURL","value":"php - cURL - PHP"},{"label":"PHP - Guzzle","value":"php - Guzzle - PHP"},{"label":"PHP - HTTP_Request2","value":"php - HTTP_Request2 - PHP"},{"label":"PHP - pecl_http","value":"php - pecl_http - PHP"},{"label":"PowerShell - RestMethod","value":"powershell - RestMethod - PowerShell"},{"label":"Python - http.client","value":"python - http.client - Python"},{"label":"Python - Requests","value":"python - Requests - Python"},{"label":"R - httr","value":"r - httr - R"},{"label":"R - RCurl","value":"r - RCurl - R"},{"label":"Ruby - Net::HTTP","value":"ruby - Net::HTTP - Ruby"},{"label":"Shell - Httpie","value":"shell - Httpie - Shell"},{"label":"Shell - wget","value":"shell - wget - Shell"},{"label":"Swift - URLSession","value":"swift - URLSession - Swift"}],"layoutOptions":[{"value":"classic-single-column","label":"Single Column"},{"value":"classic-double-column","label":"Double Column"}],"versionOptions":[],"environmentOptions":[{"value":"0","label":"No Environment"},{"label":"Production","value":"33771924-5ee5b2eb-0d5b-4805-82ec-54208dcc09e6"}],"canonicalUrl":"https://documenter.gw.postman.com/view/metadata/2sA3BkasEf"}