{"id":15069174,"url":"https://github.com/uakihir0/kmastodon","last_synced_at":"2026-01-02T08:37:55.206Z","repository":{"id":232177031,"uuid":"783390459","full_name":"uakihir0/kmastodon","owner":"uakihir0","description":"Kotlin multiplatform Mastodon library.","archived":false,"fork":false,"pushed_at":"2024-04-13T18:11:02.000Z","size":243,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-14T07:00:44.016Z","etag":null,"topics":["ios","js","jvm","kotlin","kotlin-library","kotlin-multiplatform","macos"],"latest_commit_sha":null,"homepage":"","language":"Kotlin","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/uakihir0.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2024-04-07T18:56:49.000Z","updated_at":"2024-04-20T20:39:13.309Z","dependencies_parsed_at":"2024-04-13T19:22:08.676Z","dependency_job_id":"05ca3e05-2a30-4168-ac54-7e37f3f74b9d","html_url":"https://github.com/uakihir0/kmastodon","commit_stats":null,"previous_names":["uakihir0/kmastodon"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uakihir0%2Fkmastodon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uakihir0%2Fkmastodon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uakihir0%2Fkmastodon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/uakihir0%2Fkmastodon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/uakihir0","download_url":"https://codeload.github.com/uakihir0/kmastodon/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243837017,"owners_count":20355814,"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":["ios","js","jvm","kotlin","kotlin-library","kotlin-multiplatform","macos"],"created_at":"2024-09-25T01:40:53.318Z","updated_at":"2026-01-02T08:37:55.161Z","avatar_url":"https://github.com/uakihir0.png","language":"Kotlin","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e [日本語](./docs/README_ja.md)\n\n# kmastodon\n\n![Maven metadata URL](https://img.shields.io/maven-metadata/v?metadataUrl=https%3A%2F%2Frepo.repsy.io%2Fmvn%2Fuakihir0%2Fpublic%2Fwork%2Fsocialhub%2Fkmastodon%2Fcore%2Fmaven-metadata.xml)\n\n![badge][badge-js]\n![badge][badge-jvm]\n![badge][badge-ios]\n![badge][badge-mac]\n\n**This library is a Mastodon client library that supports [Kotlin Multiplatform](https://kotlinlang.org/docs/multiplatform.html).**\nIt depends on [khttpclient] and internally uses Ktor Client.\nTherefore, this library is available on Kotlin Multiplatform and platforms supported by Ktor Client.\nThe behavior on each platform depends on [khttpclient].\n\n## Usage\n\nBelow is how to use it in Kotlin with Gradle on supported platforms.\n**If you want to use it on Apple platforms, please refer to [kmastodon-cocoapods](https://github.com/uakihir0/kmastodon-cocoapods).**\n**Also, for usage in JavaScript, please refer to [kmastodon.js](https://github.com/uakihir0/kmastodon.js).**\nPlease refer to the test code for how to use each API.\n\n```kotlin:build.gradle.kts\nrepositories {\n    mavenCentral()\n+   maven { url = uri(\"https://repo.repsy.io/mvn/uakihir0/public\") }\n}\n\ndependencies {\n+   implementation(\"work.socialhub.kmastodon:core:0.0.1-SNAPSHOT\")\n+   implementation(\"work.socialhub.kmastodon:stream:0.0.1-SNAPSHOT\")\n}\n```\n\n### Authentication\n\nFirst, create an application and request application information from the server.\n\n```kotlin\nval mastodon = MastodonFactory.instance({{HOST}})\n\nval response = mastodon.apps().registerApplication(\n    AppsRegisterApplicationRequest().also {\n        it.name = {{APP_NAME}}\n        it.website = {{APP_WEBSITE}}\n        it.redirectUris = {{REDIRECT_URI}}\n        it.scopes = \"read write follow push\"\n    }\n)\n\nprintln(response.data.clientId)\nprintln(response.data.clientSecret)\n```\n\nNext, request the URL for users to authenticate as follows.\n\n```kotlin\nval response = mastodon.oauth().authorizationUrl(\n    OAuthAuthorizationUrlRequest().also {\n        it.clientId = {{CLIENT_ID}}\n        it.redirectUri = {{REDIRECT_URI}}\n        it.scopes = \"read write follow push\"\n    }\n)\n\nprintln(response.data)\n```\n\nAfter the user authenticates and is redirected, obtain the code from the redirected URL query and get the access token as follows.\n\n```kotlin\nval response = mastodon.oauth().issueAccessTokenWithAuthorizationCode(\n    OAuthIssueAccessTokenWithAuthorizationCodeRequest().also {\n        it.clientId = {{CLIENT_ID}}\n        it.clientSecret = {{CLIENT_SECRET}}\n        it.redirectUri = {{REDIRECT_URI}}\n        it.code = \"CODE\"\n    }\n)\n\nprintln(response.data.accessToken)\n```\n\n### Create Note\n\n```kotlin\nval mastodon = MastodonFactory.instance(\n    {{HOST}}, {{ACCESS_TOKEN}}\n)\n\nmastodon.statuses().postStatus(\n    StatusesPostStatusRequest().also {\n        it.status = \"Post from kmastodon! for test.\" + \"\\n\" +\n                \"https://github.com/uakihir0/kmastodon\"\n    }\n)\n```\n\n## License\n\nMIT License\n\n## Author\n\n[Akihiro Urushihara](https://github.com/uakihir0)\n\n[khttpclient]: https://github.com/uakihir0/khttpclient\n[badge-android]: http://img.shields.io/badge/-android-6EDB8D.svg\n[badge-android-native]: http://img.shields.io/badge/support-[AndroidNative]-6EDB8D.svg\n[badge-wearos]: http://img.shields.io/badge/-wearos-8ECDA0.svg\n[badge-jvm]: http://img.shields.io/badge/-jvm-DB413D.svg\n[badge-js]: http://img.shields.io/badge/-js-F8DB5D.svg\n[badge-js-ir]: https://img.shields.io/badge/support-[IR]-AAC4E0.svg\n[badge-nodejs]: https://img.shields.io/badge/-nodejs-68a063.svg\n[badge-linux]: http://img.shields.io/badge/-linux-2D3F6C.svg\n[badge-windows]: http://img.shields.io/badge/-windows-4D76CD.svg\n[badge-wasm]: https://img.shields.io/badge/-wasm-624FE8.svg\n[badge-apple-silicon]: http://img.shields.io/badge/support-[AppleSilicon]-43BBFF.svg\n[badge-ios]: http://img.shields.io/badge/-ios-CDCDCD.svg\n[badge-mac]: http://img.shields.io/badge/-macos-111111.svg\n[badge-watchos]: http://img.shields.io/badge/-watchos-C0C0C0.svg\n[badge-tvos]: http://img.shields.io/badge/-tvos-808080.svg","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuakihir0%2Fkmastodon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuakihir0%2Fkmastodon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuakihir0%2Fkmastodon/lists"}