{"id":15134225,"url":"https://github.com/skeptick/vk-api-kotlin-client","last_synced_at":"2025-09-29T03:30:42.108Z","repository":{"id":236384356,"uuid":"139193533","full_name":"Skeptick/vk-api-kotlin-client","owner":"Skeptick","description":"Kotlin/Multiplatform библиотека для работы с API vk.com","archived":true,"fork":false,"pushed_at":"2021-08-19T07:55:16.000Z","size":357,"stargazers_count":8,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-27T05:03:34.446Z","etag":null,"topics":["kotlin","kotlin-multiplatform","kotlin-native","multiplaform","vk","vk-api","vk-client","vk-sdk","vkontakte","vkontakte-api","vkontakte-client","vkontakte-sdk"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Skeptick.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-06-29T20:36:14.000Z","updated_at":"2023-11-10T09:27:24.000Z","dependencies_parsed_at":"2024-04-26T21:24:24.386Z","dependency_job_id":"3db0d76e-6c4b-4a76-bd7f-f0e91574df5a","html_url":"https://github.com/Skeptick/vk-api-kotlin-client","commit_stats":null,"previous_names":["skeptick/vk-api-kotlin-client"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skeptick%2Fvk-api-kotlin-client","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skeptick%2Fvk-api-kotlin-client/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skeptick%2Fvk-api-kotlin-client/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Skeptick%2Fvk-api-kotlin-client/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Skeptick","download_url":"https://codeload.github.com/Skeptick/vk-api-kotlin-client/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":234583683,"owners_count":18856280,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kotlin","kotlin-multiplatform","kotlin-native","multiplaform","vk","vk-api","vk-client","vk-sdk","vkontakte","vkontakte-api","vkontakte-client","vkontakte-sdk"],"created_at":"2024-09-26T05:03:53.894Z","updated_at":"2025-09-29T03:30:36.727Z","avatar_url":"https://github.com/Skeptick.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"VK API Kotlin Client\n======================\n[![Kotlin 1.4.10](https://img.shields.io/badge/Kotlin-1.4.10-blue.svg?style=flat)](http://kotlinlang.org)\n[![Bintray Download](https://img.shields.io/bintray/v/skeptick/maven/vk-api-kotlin-client?label=Bintray)](https://bintray.com/skeptick/maven/vk-api-kotlin-client/_latestVersion)\n[![VK API](https://img.shields.io/badge/VK%20API-5.103-blue.svg?style=flat\u0026logo=vk\u0026logoColor=white)](https://vk.com/dev/versions)\n\n### В связи с закрытием Bintray библиотека нигде не опубликована, не поддерживается, и из-за любви VK ломать обратную совместимость к использованию не рекомендуется.\n\n#### Использует:\n  - [kotlinx.coroutines]\n  - [kotlinx.serialization]\n  - [ktor-client]\n\n\n\n#### Статус покрытия методов API:\n| Раздел          | Кол-во методов |                          |\n| --------------- | :------------: | -                        |\n| [Account]       |    18 из 19    | :heavy_check_mark:       |\n| [AppWidgets]    |     0 из 8     | :heavy_multiplication_x: |\n| [Apps]          |     0 из 8     | :heavy_multiplication_x: |\n| [Auth]          |     0 из 2     | :heavy_multiplication_x: |\n| [Board]         |     0 из 13    | :heavy_multiplication_x: |\n| [Database]      |     0 из 10    | :heavy_multiplication_x: |\n| [Docs]          |    11 из 11    | :heavy_check_mark:       |\n| [Fave]          |    23 из 23    | :heavy_check_mark:       |\n| [Friends]       |    18 из 18    | :heavy_check_mark:       |\n| [Gifts]         |     1 из 1     | :heavy_check_mark:       |\n| [Groups]        |    46 из 46    | :heavy_check_mark:       |\n| [LeadForms]     |     0 из 7     | :heavy_multiplication_x: |\n| [Likes]         |     4 из 4     | :heavy_check_mark:       |\n| [Market]        |     0 из 24    | :heavy_multiplication_x: |\n| [Messages]      |    39 из 39    | :heavy_check_mark:       |\n| [Newsfeed]      |     0 из 16    | :heavy_multiplication_x: |\n| [Notes]         |     0 из 10    | :heavy_multiplication_x: |\n| [Notifications] |     0 из 3     | :heavy_multiplication_x: |\n| [Pages]         |     0 из 8     | :heavy_multiplication_x: |\n| [Photos]        |    46 из 46    | :heavy_check_mark:       |\n| [Polls]         |     0 из 9     | :heavy_multiplication_x: |\n| [PrettyCards]   |     0 из 6     | :heavy_multiplication_x: |\n| [Search]        |     0 из 1     | :heavy_multiplication_x: |\n| [Stats]         |     0 из 3     | :heavy_multiplication_x: |\n| [Status]        |     0 из 2     | :heavy_multiplication_x: |\n| [Storage]       |     0 из 3     | :heavy_multiplication_x: |\n| [Stories]       |     0 из 13    | :heavy_multiplication_x: |\n| [Streaming]     |     0 из 5     | :heavy_multiplication_x: |\n| [Users]         |     7 из 6     | :heavy_check_mark:       |\n| [Utils]         |     7 из 7     | :heavy_check_mark:       |\n| [Video]         |    24 из 24    | :heavy_check_mark:       |\n| [Wall]          |    23 из 23    | :heavy_check_mark:       |\n| [Widgets]       |     0 из 2     | :heavy_multiplication_x: |\n\n#### Зачем и чтобы что\nБиблиотека пишется руками (:see_no_evil:), так как документация у VK не редко серьезно хромает. Преследуется цель сделать использование библиотеки максимально комфортным в плоскости одной из главных фич языка - nullable-типов, а также задействовать другие его особенности: корутины, мультиплатформенный HTTP-клиент (ktor) и мультиплатформенную сериализацию, опциональные именованные параметры функций заместо билдеров и т.д.\n\nБиблиотека доступна для большинства платформ (весь список расположен выше), в том числе для Android и iOS.\n\nПримеры использования\n--------------------\n#### Подготовка\nПервым делом подключите подходящий вам [HTTP-клиент](https://github.com/ktorio/ktor/tree/master/ktor-client), например CIO:\n```\nimplementation \"io.ktor:ktor-client-cio:1.4.0\"\n```\nДля Android используейте `ktor-client-okhttp` или `ktor-client-android`, для server-side рекомендую `ktor-client-apache`. Подробнее см. в [документации](https://ktor.io/clients/http-client/engines.html) и в [репозиториях](https://github.com/ktorio/ktor/tree/master/ktor-client) ktor.\n\n#### Инициализация клиента\n```kotlin\nval apiClient = VkApiClient(\"your_token\", HttpClient(CIO))\nval api = VkApiUser(apiClient) // для токена пользователя\nval api = VkApiCommunity(apiClient) // для токена сообщества\n```\n#### Использование методов\n```kotlin\n// отправка сообщения\nval sendResult = api.messages.send(peerId = 1000000, message = \"Hello!\").execute()\n\n// получение первых десяти друзей в алфавитном порядке\nval friendsResult = api.friends.get(order = FriendsOrder.NAME, count = 10).execute()\n```\n#### Обработка результата\nВ качестве результата любого запроса возвращается ~~монада~~ объект [VkResult](vk-api-kotlin-client/src/main/kotlin/tk/skeptick/vk/apiclient/VkResult.kt). Подробнее ознакомиться с концепцией и примерами использования можно в [ReadMe библиотеки](https://github.com/kittinunf/Result), копипастом с которой он является (увы, сама библиотека Kotlin/Multiplatform не поддерживает).\n#### Загрузка файлов (на примере документа)\n```kotlin\nval file = File(\"file.txt\")\nval fileContent = FileContent(file.name, file.readBytes())\nval documents = api.docs.getUploadServer().execute()\n    .flatMap { api.upload.document(it.uploadUrl, fileContent).execute() }\n    .flatMap { api.docs.save(it.file, \"Title.txt\").execute() }\n```\n#### Использование метода `execute`\nОпишите модель ответа (или используйте имеющиеся):\n```kotlin\n@Serializable\ndata class ExampleResponse(\n    @SerialName(\"id\") val id: Int,\n    @SerialName(\"value\") val value: String\n)\n```\nКод для выполнения на сервере:\n```kotlin\nval exampleCode = \"\"\"\n    var response = [];\n    var i = 0;\n\n    while (i \u003c 10) {\n        response.push({\n            \"id\": i,\n            \"value\": \"something\"\n        });\n\n        i = i + 1;\n    }\n\n    return response;\n\"\"\".trimIndent()\n```\nВызовите метод:\n```kotlin\nval executeResult = api.execute(\n    code = exampleCode,\n    serializer = ExampleResponse.serializer().list\n).execute()\n```\n\nДополнительно\n--------------------\n#### Работа с битовыми масками\n```kotlin\nval scope = AccessPermissionsUser().apply { \n    friends = true\n    photos = true\n    messages = true\n}.mask\n```\n#### DSL-builder клавиатуры для сообщений сообществ\n```kotlin\n@Serializable\ndata class ExamplePayload(@SerialName(\"key\") val key: String)\n\nkeyboard { \n    buttonsRow { \n        positiveButton(\"OK\")\n    }\n    buttonsRow { \n        defaultButton(\"Button with payload\") {\n            payload = MessagePayload.from(ExamplePayload(\"value\"))\n        }\n        defaultButton(\"Simple button\")\n    }\n    buttonsRow { \n        negativeButton(\"Cancel\")\n    }\n}\n```\n#### Конвертация идентификаторов\n```kotlin\n1.chatIdToPeerId // == 2000000001\n1.communityIdToPeerId // == -1\n\n2000000001.peerIdToChatId // == 1\n-1.peerIdToCommunityId // == 1\n\n2000000001.isChatPeerId // == true\n-1.isCommunityPeerId // == true\n1.isUserPeerId // == true\n```\n\nLicense\n=======\n\n    Copyright 2020 Danil Yudov\n    \n    Licensed under the Apache License, Version 2.0 (the \"License\");\n    you may not use this file except in compliance with the License.\n    You may obtain a copy of the License at\n    \n       http://www.apache.org/licenses/LICENSE-2.0\n       \n    Unless required by applicable law or agreed to in writing, software\n    distributed under the License is distributed on an \"AS IS\" BASIS,\n    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n    See the License for the specific language governing permissions and\n    limitations under the License.\n\n[kotlinx.coroutines]: \u003chttps://github.com/Kotlin/kotlinx.coroutines\u003e\n[kotlinx.serialization]: \u003chttps://github.com/Kotlin/kotlinx.serialization\u003e\n[ktor-client]: \u003chttps://github.com/ktorio/ktor/tree/master/ktor-client\u003e\n\n[Account]: \u003chttps://vk.com/dev/account\u003e\n[AppWidgets]: \u003chttps://vk.com/dev/appWidgets\u003e\n[Apps]: \u003chttps://vk.com/dev/apps\u003e\n[Auth]: \u003chttps://vk.com/dev/auth\u003e\n[Board]: \u003chttps://vk.com/dev/board\u003e\n[Database]: \u003chttps://vk.com/dev/database\u003e\n[Docs]: \u003chttps://vk.com/dev/docs\u003e\n[Fave]: \u003chttps://vk.com/dev/fave\u003e\n[Friends]: \u003chttps://vk.com/dev/friends\u003e\n[Gifts]: \u003chttps://vk.com/dev/gifts\u003e\n[Groups]: \u003chttps://vk.com/dev/groups\u003e\n[LeadForms]: \u003chttps://vk.com/dev/leadForms\u003e\n[Likes]: \u003chttps://vk.com/dev/likes\u003e\n[Market]: \u003chttps://vk.com/dev/market\u003e\n[Messages]: \u003chttps://vk.com/dev/messages\u003e\n[Newsfeed]: \u003chttps://vk.com/dev/newsfeed\u003e\n[Notes]: \u003chttps://vk.com/dev/notes\u003e\n[Notifications]: \u003chttps://vk.com/dev/notifications\u003e\n[Pages]: \u003chttps://vk.com/dev/pages\u003e\n[Photos]: \u003chttps://vk.com/dev/photos\u003e\n[Polls]: \u003chttps://vk.com/dev/polls\u003e\n[PrettyCards]: \u003chttps://vk.com/dev/prettyCards\u003e\n[Search]: \u003chttps://vk.com/dev/search\u003e\n[Stats]: \u003chttps://vk.com/dev/stats\u003e\n[Status]: \u003chttps://vk.com/dev/status\u003e\n[Storage]: \u003chttps://vk.com/dev/storage\u003e\n[Stories]: \u003chttps://vk.com/dev/stories\u003e\n[Streaming]: \u003chttps://vk.com/dev/streaming\u003e\n[Users]: \u003chttps://vk.com/dev/users\u003e\n[Utils]: \u003chttps://vk.com/dev/utils\u003e\n[Video]: \u003chttps://vk.com/dev/video\u003e\n[Wall]: \u003chttps://vk.com/dev/wall\u003e\n[Widgets]: \u003chttps://vk.com/dev/widgets\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskeptick%2Fvk-api-kotlin-client","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fskeptick%2Fvk-api-kotlin-client","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fskeptick%2Fvk-api-kotlin-client/lists"}