{"_id":"57e382eef727c41700002012","user":"5631f962c3b04b0d00ba9bf1","__v":0,"category":{"_id":"57e0f14b8929550e00f1d9bc","__v":0,"version":"5703d527bb69fc1700553ce3","project":"5703d527bb69fc1700553ce0","sync":{"url":"","isSync":false},"reference":false,"createdAt":"2016-09-20T08:20:27.114Z","from_sync":false,"order":4,"slug":"api-module","title":"Api module"},"parentDoc":null,"githubsync":"","project":"5703d527bb69fc1700553ce0","version":{"_id":"5703d527bb69fc1700553ce3","hasDoc":true,"__v":6,"hasReference":true,"project":"5703d527bb69fc1700553ce0","createdAt":"2016-04-05T15:09:27.620Z","releaseDate":"2016-04-05T15:09:27.620Z","categories":["5703d527bb69fc1700553ce4","5703d8b7aceacc17003ef303","5703e60b6116142000db25f6","57e0db616a1c2e0e0081fe64","57e0f141ff540c22007b45fa","57e0f14b8929550e00f1d9bc"],"is_deprecated":false,"is_hidden":false,"is_beta":true,"is_stable":true,"codename":"","version_clean":"0.0.6","version":"0.0.6"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-09-22T07:06:22.842Z","link_external":false,"link_url":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":false,"order":0,"body":"This class is the main entry point of the library, this is the first class that you should be using.\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Create a new client\"\n}\n[/block]\nThe easiest way is\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Kotlogram.getDefaultClient(application, new TelegramApiStorageImpl());\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\nHere, the `TelegramApiStorageImpl` is not detailed, but your implementation should persist info in persistent memory (DB, file, ...).\n\nOr, you may also use this method overloads\n- `preferredDataCenter`: if you want to try connecting to a specific datacenter first (for example, if you know your closest dc). It could save some exchange (a few ms...) while creating the first client.\n- `updateCallback`: callback called when an update is received from Telegram (new message, new group created, new friend joined Telegram, ...).\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Get a specific DataCenter\"\n}\n[/block]\nYou can use `getDcById` method or `getDcId` methods :)\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Get API layer at runtime\"\n}\n[/block]\n\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"int layer = Kotlogram.API_LAYER;\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]\n\n[block:api-header]\n{\n  \"type\": \"basic\",\n  \"title\": \"Clean up\"\n}\n[/block]\nOnce you're done, and you closed all your clients, to let your process finish, call:\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"Kotlogram.cleanUp();\",\n      \"language\": \"java\"\n    }\n  ]\n}\n[/block]","excerpt":"com.github.badoualy.telegram.api.Kotlogram","slug":"kotlogram","type":"basic","title":"Kotlogram"}

Kotlogram

com.github.badoualy.telegram.api.Kotlogram

This class is the main entry point of the library, this is the first class that you should be using. [block:api-header] { "type": "basic", "title": "Create a new client" } [/block] The easiest way is [block:code] { "codes": [ { "code": "Kotlogram.getDefaultClient(application, new TelegramApiStorageImpl());", "language": "java" } ] } [/block] Here, the `TelegramApiStorageImpl` is not detailed, but your implementation should persist info in persistent memory (DB, file, ...). Or, you may also use this method overloads - `preferredDataCenter`: if you want to try connecting to a specific datacenter first (for example, if you know your closest dc). It could save some exchange (a few ms...) while creating the first client. - `updateCallback`: callback called when an update is received from Telegram (new message, new group created, new friend joined Telegram, ...). [block:api-header] { "type": "basic", "title": "Get a specific DataCenter" } [/block] You can use `getDcById` method or `getDcId` methods :) [block:api-header] { "type": "basic", "title": "Get API layer at runtime" } [/block] [block:code] { "codes": [ { "code": "int layer = Kotlogram.API_LAYER;", "language": "java" } ] } [/block] [block:api-header] { "type": "basic", "title": "Clean up" } [/block] Once you're done, and you closed all your clients, to let your process finish, call: [block:code] { "codes": [ { "code": "Kotlogram.cleanUp();", "language": "java" } ] } [/block]