{"info":{"_postman_id":"46dc183f-7773-42d6-a795-22764fc8fbb4","name":"Messenger","description":"<html><head></head><body><p>Project (APIs) Documentation</p>\n<p>This is documentation about my messanger 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":"46dc183f-7773-42d6-a795-22764fc8fbb4","publishedId":"2s9Yyy9Jru","public":true,"customColor":{"top-bar":"FFFFFF","right-sidebar":"303030","highlight":"FF6C37"},"publishDate":"2024-02-07T18:06:02.000Z"},"item":[{"name":"User APIs","item":[{"name":"User Register","id":"9389c488-2dbe-46f1-8fc3-1857483b9eae","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"username\": \"sla1k11sla1\",\n    \"password\": \"123456789\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/user/register","description":"<p>To register a user you need to pass in body json:</p>\n<ul>\n<li><p>username - with length from 6 to 16 and without specific characters</p>\n</li>\n<li><p>password - with length from 8 to 16, which will be saved to the database encrypted</p>\n</li>\n</ul>\n","urlObject":{"protocol":"http","port":"8001","path":["user","register"],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"1e2a7bfd-710c-4447-9f02-d9d0ffaa0c12","name":"User Register","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"username\": \"sla1k11sla1\",\n    \"password\": \"123456789\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/user/register"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Wed, 07 Feb 2024 18:03:20 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"53"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"user_id\": \"65c3c5e8086be4d2bc75d84f\"\n}"}],"_postman_id":"9389c488-2dbe-46f1-8fc3-1857483b9eae"},{"name":"Login","id":"7421f5ce-b3d1-4953-8366-ecc8ac146b45","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"username\": \"sla1k11sla1\",\n    \"password\": \"123456789\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/user/login","description":"<p>For login you need to enter the user's details:</p>\n<ul>\n<li>username</li>\n<li>password</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":"8001","path":["user","login"],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"4b089c48-a9ff-4b46-89e4-61183afdc73a","name":"Login","originalRequest":{"method":"POST","header":[],"body":{"mode":"raw","raw":"{\n    \"username\": \"sla1k11sla1\",\n    \"password\": \"123456789\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/user/login"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Wed, 07 Feb 2024 18:57:23 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"228"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"user_id\": \"65c3c5e8086be4d2bc75d84f\",\n    \"username\": \"sla1k11sla1\",\n    \"access_token\": \"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzbGExazExc2xhMSIsImV4cCI6MTcwNzMzNDA0M30.rSjrk-EXt1SKb2PCYny_gn4PUkOCnAkOcHNsn6brs9Q\"\n}"}],"_postman_id":"7421f5ce-b3d1-4953-8366-ecc8ac146b45"}],"id":"a327a9ff-e10a-4ae1-90c7-7edf362d28fe","description":"<p>User APIs Documentation</p>\n","_postman_id":"a327a9ff-e10a-4ae1-90c7-7edf362d28fe"},{"name":"Chat","item":[{"name":"Create Chat","id":"33599901-48ea-4dc7-bcbf-c5d4f3f52e00","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzbGExazExc2xhMSIsImV4cCI6MTcwNzQzNzk4Nn0.I-UjXan-KLdvJTYff1gsp8QhHJkdqdKP-L7NdU_nE5A","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"username\": \"test_user\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/chat/create","description":"<p>To create a chat between two users, you need to pass in a query:</p>\n<p>In Headers:</p>\n<ul>\n<li>Authorization: Bearer {access_token} - where access_token is the JWT token that is in the response from /login to validate the user</li>\n</ul>\n<p>In body json:</p>\n<ul>\n<li>username - username of the user from whom to create chat</li>\n</ul>\n<p>In the response we will get chat_id which we will need later to access the chat room</p>\n","urlObject":{"protocol":"http","port":"8001","path":["chat","create"],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"e4b532a8-fd1c-41d0-90cd-73db08c2761c","name":"Create Chat","originalRequest":{"method":"POST","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzbGExazExc2xhMSIsImV4cCI6MTcwNzQzNzk4Nn0.I-UjXan-KLdvJTYff1gsp8QhHJkdqdKP-L7NdU_nE5A","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"username\": \"test_user\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/chat/create"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Fri, 09 Feb 2024 00:09:49 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"115"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"user_a_username\": \"sla1k11sla1\",\n    \"user_b_username\": \"test_user\",\n    \"chat_id\": \"65c56d4d4422f78704d09e37\"\n}"}],"_postman_id":"33599901-48ea-4dc7-bcbf-c5d4f3f52e00"}],"id":"f92c3e01-0cb2-4c34-82c7-1732357ceb5d","description":"<p>Chat APIs Documentation</p>\n","_postman_id":"f92c3e01-0cb2-4c34-82c7-1732357ceb5d"},{"name":"Messages","item":[{"name":"Send Message","id":"5e0694ae-60fd-46f0-8ed8-235c6980ad04","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"POST","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzbGExazExc2xhMSIsImV4cCI6MTcwNzUwMDg1MX0.3RCozl-cfdFBzbceNAfFXUipEOEpY2kfmbnL4e1N4Y8","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"chat_id\": \"65c65f0f02e55d5eb5642f80\",\n    \"message\": \"Hello\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/send-message","description":"<p>To send messages you need to pass in the request:</p>\n<p>In Headers:</p>\n<ul>\n<li>Authorization: Bearer {access_token} - where access_token is the JWT token that is in the response from /login to validate the user</li>\n</ul>\n<p>In body json:</p>\n<ul>\n<li>chat_id - send a message to the specified chat room</li>\n<li>message - the text that will be sent</li>\n</ul>\n<p>And a websocket is created on the request ws://127.0.0.1:8001/chat/{chat_id}.</p>\n<p>Data is written to the cache to make fewer queries to the database.</p>\n","urlObject":{"protocol":"http","port":"8001","path":["send-message"],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"3f0ad4b8-9c4f-40d1-9e5d-2c05886f5250","name":"Send Message","originalRequest":{"method":"POST","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzbGExazExc2xhMSIsImV4cCI6MTcwNzUwMDg1MX0.3RCozl-cfdFBzbceNAfFXUipEOEpY2kfmbnL4e1N4Y8","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"chat_id\": \"65c65f0f02e55d5eb5642f80\",\n    \"message\": \"Hello\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/send-message"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Fri, 09 Feb 2024 17:45:21 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"54"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"message\": \"Message sent successfully\"\n}"}],"_postman_id":"5e0694ae-60fd-46f0-8ed8-235c6980ad04"},{"name":"Get Messages","id":"911ab068-b15f-4b10-958a-932b006bc288","protocolProfileBehavior":{"disableBodyPruning":true},"request":{"method":"GET","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzbGExazExc2xhMSIsImV4cCI6MTcwNzUzMTg0N30._AFNSfwoBPO3XMfgPqzn2NEs4XRYuxNooJfyu6qKz80","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"chat_id\": \"65c65f0f02e55d5eb5642f80\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/messages","description":"<p>To get messages from chat you need to pass in the request:</p>\n<p>In Headers:</p>\n<ul>\n<li>Authorization: Bearer {access_token} - where access_token is the JWT token that is in the response from /login to validate the user</li>\n</ul>\n<p>In body json:</p>\n<ul>\n<li>chat_id - from which chat room to retrieve messages</li>\n</ul>\n<p>If there is data in the cache, we retrieve it from there, if there is no data in the cache, we query the database.</p>\n","urlObject":{"protocol":"http","port":"8001","path":["messages"],"host":["127","0","0","1"],"query":[],"variable":[]}},"response":[{"id":"4d352ee4-d17e-4da3-9e53-9b1ca2cfd71f","name":"Get Messages","originalRequest":{"method":"GET","header":[{"key":"Authorization","value":"Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiJzbGExazExc2xhMSIsImV4cCI6MTcwNzUzMTg0N30._AFNSfwoBPO3XMfgPqzn2NEs4XRYuxNooJfyu6qKz80","type":"text"}],"body":{"mode":"raw","raw":"{\n    \"chat_id\": \"65c65f0f02e55d5eb5642f80\"\n}","options":{"raw":{"language":"json"}}},"url":"http://127.0.0.1:8001/messages"},"status":"OK","code":200,"_postman_previewlanguage":"json","header":[{"key":"date","value":"Sat, 10 Feb 2024 00:24:19 GMT"},{"key":"server","value":"uvicorn"},{"key":"content-length","value":"650"},{"key":"content-type","value":"application/json"}],"cookie":[],"responseTime":null,"body":"{\n    \"success\": true,\n    \"chat_id\": \"65c65f0f02e55d5eb5642f80\",\n    \"messages\": [\n        {\n            \"from\": \"sla1k11sla1\",\n            \"to\": \"testuese\",\n            \"message\": \"Hello from 2\",\n            \"send_in\": \"2024-02-09T23:18:14.688000\"\n        },\n        {\n            \"from\": \"sla1k11sla1\",\n            \"to\": \"testuese\",\n            \"message\": \"Hello\",\n            \"send_in\": \"2024-02-09T23:18:06.553000\"\n        },\n        {\n            \"from\": \"testuese\",\n            \"to\": \"sla1k11sla1\",\n            \"message\": \"Hello\",\n            \"send_in\": \"2024-02-09T23:06:58.332000\"\n        },\n        {\n            \"from\": \"testuese\",\n            \"to\": \"sla1k11sla1\",\n            \"message\": \"Hello2\",\n            \"send_in\": \"2024-02-09T23:06:53.257000\"\n        },\n        {\n            \"from\": \"testuese\",\n            \"to\": \"sla1k11sla1\",\n            \"message\": \"Hello\",\n            \"send_in\": \"2024-02-09T23:06:50.928000\"\n        },\n        {\n            \"from\": \"testuese\",\n            \"to\": \"sla1k11sla1\",\n            \"message\": \"Hello\",\n            \"send_in\": \"2024-02-09T23:06:49.724000\"\n        }\n    ]\n}"}],"_postman_id":"911ab068-b15f-4b10-958a-932b006bc288"}],"id":"19b8bb39-41ae-4f98-b4d0-b0530fe6f7bd","description":"<p>Messages APIs Documentation</p>\n","_postman_id":"19b8bb39-41ae-4f98-b4d0-b0530fe6f7bd"}]}