{"info":{"_postman_id":"41d214dc-b464-4c8c-be33-83aa72098432","name":"SpaApp","description":"<html><head></head><body><p>Project (APIs) Documentation</p>\n<p>This is documentation about my SPA App project and here you can find and understand how the APIs of this project work</p>\n</body></html>","schema":"https://schema.getpostman.com/json/collection/v2.0.0/collection.json","toc":[],"owner":"26500283","collectionId":"41d214dc-b464-4c8c-be33-83aa72098432","publishedId":"2sA2rGvKJz","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2024-02-29T16:10:24.000Z"},"item":[{"name":"User","item":[{"name":"Register","id":"035a73fd-d97d-42a2-bb0b-b1c2d3b95aa5","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"username\": \"test\",\n    \"password\": \"123456789\",\n    \"email\": \"test@gamail.com\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/user/register","description":"<p>To register a user you need to pass in body json:</p>\n<ul>\n<li><p>username - with max length 30</p>\n</li>\n<li><p>password - with max length 20 which will be stored in the database in coded format</p>\n</li>\n<li><p>email - valid email</p>\n</li>\n</ul>\n","urlObject":{"protocol":"http","port":"8000","path":["user","register"],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"385672cb-2ea1-452b-a4d9-aeb6541cc545","name":"Register","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"username\": \"test\",\n    \"password\": \"123456789\",\n    \"email\": \"test@gamail.com\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/user/register"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Frame-Options","value":"DENY"},{"key":"Content-Length","value":"151"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Referrer-Policy","value":"same-origin"},{"key":"Cross-Origin-Opener-Policy","value":"same-origin"},{"key":"Server","value":"daphne"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"user\": {\n        \"pk\": 2,\n        \"username\": \"test\",\n        \"email\": \"test@gamail.com\",\n        \"home_page\": \"\",\n        \"created_at\": \"2024-02-29T17:22:55.833768+00:00\"\n    }\n}"}],"_postman_id":"035a73fd-d97d-42a2-bb0b-b1c2d3b95aa5"},{"name":"Login","id":"af1e8c79-e6b7-4dae-af66-07085fe28127","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"username\": \"test\",\n    \"password\": \"123456789\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/user/login","description":"<p>For login you need to enter the user's details:</p>\n<ul>\n<li><p>username</p>\n</li>\n<li><p>password</p>\n</li>\n</ul>\n<p>In the response you should get an access_token, which will be needed in the future to use APIs</p>\n","urlObject":{"protocol":"http","port":"8000","path":["user","login"],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"2d76b2d4-6a15-4157-af8c-7f93a269c207","name":"Login","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"username\": \"test\",\n    \"password\": \"123456789\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/user/login"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Frame-Options","value":"DENY"},{"key":"Content-Length","value":"227"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Referrer-Policy","value":"same-origin"},{"key":"Cross-Origin-Opener-Policy","value":"same-origin"},{"key":"Server","value":"daphne"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"user\": {\n        \"id\": 2,\n        \"username\": \"test\",\n        \"email\": \"test@gamail.com\"\n    },\n    \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0IiwiZXhwIjoxNzA5MjM0NTg4fQ.Blsh8hymOHVsDwGx0XImyloE2tYqgc-AfQcn_8smPhg\"\n}"}],"_postman_id":"af1e8c79-e6b7-4dae-af66-07085fe28127"}],"id":"0b6cb5e6-1852-4ad4-97df-5016928b3663","description":"<p>User APIs Documentation</p>\n","_postman_id":"0b6cb5e6-1852-4ad4-97df-5016928b3663"},{"name":"Comment","item":[{"name":"Captcha","id":"fc2a535f-91d1-4d13-959c-9901ede2c1a6","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0IiwiZXhwIjoxNzA4NzQwMjk2fQ.zM0VSgT52EO89Y_v5NGwVAE_kkc4KDSGnSXuqB3-YNA","type":"text"}],"body":{"mode":"raw","raw":"","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/comment/captcha/create","description":"<p>Nothing is needed to create a captcha, as the token is stored in the cache and will automatically authenticate the user, although we can also enter the value of this token in Headers via</p>\n<ul>\n<li>Authorization - Bearer {token} !!! Not required (token in cache) !!!</li>\n</ul>\n","urlObject":{"protocol":"http","port":"8000","path":["comment","captcha","create"],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[],"_postman_id":"fc2a535f-91d1-4d13-959c-9901ede2c1a6"},{"name":"Create Post","id":"94169cc8-b1ee-47ab-91c0-1bfb8f500350","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0IiwiZXhwIjoxNzA4NzQwMjk2fQ.zM0VSgT52EO89Y_v5NGwVAE_kkc4KDSGnSXuqB3-YNA","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"captcha_text\": \"gvci4n\",\n    \"text\": \"Hello\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/comment/","description":"<p>For create post you need to enter the post details:</p>\n<ul>\n<li><p>Authorization - Bearer {token} !!! Not required (token in cache) !!!</p>\n</li>\n<li><p>captcha_text - you need to enter the characters from the picture of the previous request</p>\n</li>\n<li><p>text - message of this post</p>\n</li>\n</ul>\n","urlObject":{"protocol":"http","port":"8000","path":["comment",""],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"6e83a60f-63bf-4291-8230-4caf66f071be","name":"Create Post","originalRequest":{"method":"POST","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJ0ZXN0IiwiZXhwIjoxNzA4NzQwMjk2fQ.zM0VSgT52EO89Y_v5NGwVAE_kkc4KDSGnSXuqB3-YNA","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"captcha_text\": \"gqtbta\",\n    \"text\": \"Hello\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8000/comment/"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Frame-Options","value":"DENY"},{"key":"Content-Length","value":"182"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Referrer-Policy","value":"same-origin"},{"key":"Cross-Origin-Opener-Policy","value":"same-origin"},{"key":"Server","value":"daphne"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"comment\": {\n        \"id\": 1,\n        \"captcha\": true,\n        \"text\": \"Hello\",\n        \"created_at\": \"2024-02-29T17:24:02.969Z\",\n        \"user\": {\n            \"id\": 2,\n            \"username\": \"test\",\n            \"email\": \"test@gamail.com\"\n        }\n    }\n}"}],"_postman_id":"94169cc8-b1ee-47ab-91c0-1bfb8f500350"},{"name":"Get Post","id":"ff81051b-216d-4569-8a66-2c8caec634eb","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://127.0.0.1:8000/comment/?username=test&email=test2@gamail.com&date=new","description":"<p>For get posts you need to enter the filter details - in query parameters we can pass filters:</p>\n<ul>\n<li><p>Authorization - Bearer {token} !!! Not required (token in cache) !!!</p>\n</li>\n<li><p>username - username of user with which there are posts</p>\n</li>\n<li><p>email - email of user with which there are posts</p>\n</li>\n<li><p>date - 'new' or 'old' filter messages</p>\n</li>\n</ul>\n","urlObject":{"protocol":"http","port":"8000","path":["comment",""],"host":["127","0","0","1"],"query":[{"key":"username","value":"test"},{"key":"email","value":"test2@gamail.com"},{"key":"date","value":"new"}],"variable":[]}},"response":[{"id":"64ac3c06-b977-422b-b77f-c5e4f760606d","name":"Get Post","originalRequest":{"method":"GET","header":[],"url":{"raw":"http://127.0.0.1:8000/comment/?username=test&email=test2@gamail.com&date=new","protocol":"http","host":["127","0","0","1"],"port":"8000","path":["comment",""],"query":[{"key":"username","value":"test"},{"key":"email","value":"test2@gamail.com"},{"key":"date","value":"new"}]}},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"Content-Type","value":"application/json"},{"key":"X-Frame-Options","value":"DENY"},{"key":"Content-Length","value":"294"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Referrer-Policy","value":"same-origin"},{"key":"Cross-Origin-Opener-Policy","value":"same-origin"},{"key":"Server","value":"daphne"}],"cookie":[],"responseTime":null,"body":"{\n    \"comments\": [\n        {\n            \"id\": 3,\n            \"captcha\": true,\n            \"text\": \"Hello2\",\n            \"user\": 1,\n            \"created_at\": \"2024-02-29 17:25:27\"\n        },\n        {\n            \"id\": 2,\n            \"captcha\": true,\n            \"text\": \"Hello\",\n            \"user\": 1,\n            \"created_at\": \"2024-02-29 17:25:04\"\n        },\n        {\n            \"id\": 1,\n            \"captcha\": true,\n            \"text\": \"Hello\",\n            \"user\": 2,\n            \"created_at\": \"2024-02-29 17:24:02\"\n        }\n    ]\n}"}],"_postman_id":"ff81051b-216d-4569-8a66-2c8caec634eb"},{"name":"Chat","id":"9d55669d-4629-4654-8e0a-080899a8e374","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[],"url":"http://127.0.0.1:8000/comment/1/","description":"<p>The last parameter in the request we pass the id of the comment we want to get into the chat room:</p>\n<ul>\n<li>Authorization - Bearer {token} !!! Not required (token in cache) !!!</li>\n</ul>\n<p>You need to go to this request in your browser and start using chat)</p>\n","urlObject":{"protocol":"http","port":"8000","path":["comment","1",""],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"ea8d5f5a-5a72-45f3-b3a5-5052657d9a60","name":"Chat","originalRequest":{"method":"GET","header":[],"url":"http://127.0.0.1:8000/comment/1/"},"status":"OK","code":200,"_postman_previewlanguage":"html","header":[{"key":"Content-Type","value":"text/html; charset=utf-8"},{"key":"X-Frame-Options","value":"DENY"},{"key":"Content-Length","value":"1626"},{"key":"X-Content-Type-Options","value":"nosniff"},{"key":"Referrer-Policy","value":"same-origin"},{"key":"Cross-Origin-Opener-Policy","value":"same-origin"},{"key":"Server","value":"daphne"}],"cookie":[],"responseTime":null,"body":"<!DOCTYPE html>\n<html>\n    <head>\n        <meta charset=\"utf-8\"/>\n        <title>Comment Room</title>\n    </head>\n    <body>\n        <textarea id=\"chat-log\" cols=\"100\" rows=\"20\"></textarea>\n        <br>\n        <input id=\"chat-message-input\" type=\"text\" size=\"100\">\n        <br>\n        <input id=\"chat-message-submit\" type=\"button\" value=\"Send\">\n        <script id=\"comment-id\" type=\"application/json\">\"1\"</script>\n        <script>\n        const comment_id = JSON.parse(document.getElementById('comment-id').textContent);\n\n        const chatSocket = new WebSocket(\n            'ws://'\n            + window.location.host\n            + '/ws/chat/'\n            + comment_id\n            + '/'\n        );\n\n        chatSocket.onmessage = function(e) {\n            const data = JSON.parse(e.data);\n            document.querySelector('#chat-log').value += (data.message + '\\n');\n        };\n\n        chatSocket.onclose = function(e) {\n            console.error('Chat socket closed unexpectedly');\n        };\n\n        document.querySelector('#chat-message-input').focus();\n        document.querySelector('#chat-message-input').onkeyup = function(e) {\n            if (e.keyCode === 13) {  // enter, return\n                document.querySelector('#chat-message-submit').click();\n            }\n        };\n\n        document.querySelector('#chat-message-submit').onclick = function(e) {\n            const messageInputDom = document.querySelector('#chat-message-input');\n            const message = messageInputDom.value;\n            chatSocket.send(JSON.stringify({\n                'message': message\n            }));\n            messageInputDom.value = '';\n        };\n    </script>\n    </body>\n</html>"}],"_postman_id":"9d55669d-4629-4654-8e0a-080899a8e374"}],"id":"d10cf6a5-cec9-4639-9143-e498eeca1360","description":"<p>Comment APIs Documentation</p>\n","_postman_id":"d10cf6a5-cec9-4639-9143-e498eeca1360"}]}