{"id":13907790,"url":"https://github.com/notionsdk/notion-sdk-kotlin-old","last_synced_at":"2025-07-18T06:31:17.730Z","repository":{"id":144225281,"uuid":"188659162","full_name":"notionsdk/notion-sdk-kotlin-old","owner":"notionsdk","description":"Unofficial Notion.so API wrapper, written in Kotlin","archived":true,"fork":false,"pushed_at":"2021-09-07T19:12:10.000Z","size":110,"stargazers_count":67,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-25T16:39:13.991Z","etag":null,"topics":["api","java","kotlin","library","notion"],"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/notionsdk.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":"2019-05-26T08:40:27.000Z","updated_at":"2024-06-27T09:34:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"57c644d3-8386-4643-84a4-0ea2ba261d8f","html_url":"https://github.com/notionsdk/notion-sdk-kotlin-old","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/notionsdk/notion-sdk-kotlin-old","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notionsdk%2Fnotion-sdk-kotlin-old","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notionsdk%2Fnotion-sdk-kotlin-old/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notionsdk%2Fnotion-sdk-kotlin-old/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notionsdk%2Fnotion-sdk-kotlin-old/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/notionsdk","download_url":"https://codeload.github.com/notionsdk/notion-sdk-kotlin-old/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/notionsdk%2Fnotion-sdk-kotlin-old/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265710543,"owners_count":23815375,"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":["api","java","kotlin","library","notion"],"created_at":"2024-08-06T23:02:10.629Z","updated_at":"2025-07-18T06:31:17.720Z","avatar_url":"https://github.com/notionsdk.png","language":"Kotlin","funding_links":[],"categories":["HarmonyOS","API\u0026客户端"],"sub_categories":["Windows Manager","文件同步"],"readme":"# Notion SDK / Kotlin / Unofficial API\n\n# Archived: this library depends on the private APIs which are unstable and not really convenient.\n# Please use https://github.com/notionsdk/notion-sdk-kotlin\n\nUnofficial Notion API wrapper (SDK), written in Kotlin. Can be used in Java.\n\n### Install\n\n- Add `jitpack.io` to your repositories list\n\n```\nrepositories {\n    // ...\n    maven { url 'https://jitpack.io' }\n}\n```\n\n- Add library to dependencies list\n\n```\ndependencies {\n    implementation \"com.github.notionsdk:notion-sdk-kotlin:$latestVersion\"\n}\n```\n\nLatest version: https://github.com/notionsdk/notion-sdk-kotlin/releases\n\n### Auth\n#### If you have a password\nJust use your email and password:\n\n```kotlin\nval notion = Notion.fromEmailAndPassword(\n    credentials = NotionCredentials(email = \"test@test.com\", password = \"password\"),\n    /* ... */\n)\n```\n\n#### If you use a randomly generated passcode\n- Open any [notion.so](https://notion.so) page in browser (e.g. in Google Chrome)\n- Open debugging tools (you must be logged in!)\n- Obtain the `token_v2` cookie value of `https://www.notion.so/`\n\nAnd then:\n```kotlin\nval notion = Notion.fromToken(\n    token = \"your_token\",\n    /* ... */\n)\n```\n\n### Get page id\n- Open any page\n- Your link should look like `https://www.notion.so/\u003cyour_wokspace\u003e/d822369169254cc4a1b2f5bbf3e8b87b`\n- Last **path** part is page id (skip all query params), `d822369169254cc4a1b2f5bbf3e8b87b` for example above.\n\n### Mapping\n\n**Source collection:**\n\n\u003cimg src=\"https://i.imgur.com/I7n9Cx0.png\" data-canonical-src=\"https://i.imgur.com/I7n9Cx0.png\" width=\"367\" height=\"328\" /\u003e\n\nYou can use the pre-defined mapping:\n\n```kotlin\nsuspend fun main() {\n    // you need to provide your httpClient; JsonFeature must be installed!\n    val httpClient = HttpClient(CIO) {\n        Json { serializer = KotlinxSerializer(kotlinx.serialization.json.Json { ignoreUnknownKeys = true }) }\n    }\n    val notion = Notion.fromEmailAndPassword(\n        NotionCredentials(\"test@test.com\", \"password\"),\n        httpClient  // you need to provide your httpClient; JsonFeature must be installed!\n    )\n\n    // different instance for serialization \n    // because Notion's JSON is really weird for statically typed parsing\n    val json = Json {\n        ignoreUnknownKeys = true\n\n        // you need to use the discriminator if you want to serialize the table back to json\n        classDiscriminator = \"object_type\"\n    }\n    val table: NotionTable? = notion.getCollection(json, pageId = \"73ef0bcb09424b00916e6e4f6759e310\")\n\n    println(table)\n    // Output:\n    // NotionTable(\n    //    title=Some test table, \n    //    description=With test description, \n    //    rows=[\n    //        NotionRow(\n    //            properties={\n    //                checked=SingleValue(name=checked, type=Checkbox, value=NotionProperty(label=Yes, value=Checkbox(checked=true))), \n    //                value=SingleValue(name=value, type=Text, value=NotionProperty(label=some_value_0, value=Text(text=some_value_0))), \n    //                key=SingleValue(name=key, type=Title, value=NotionProperty(label=some_key_0, value=Title(text=some_key_0)))\n    //            }, \n    //            metaInfo=MetaInfo(lastEditedBy=d6a033eb-82bb-49dd-975c-82ccb739f30e, lastEditedTime=1606352460000, createdBy=d6a033eb-82bb-49dd-975c-82ccb739f30e, createdTime=1606350145225)), \n    //        NotionRow(\n    //            properties={\n    //                key=SingleValue(name=key, type=Title, value=NotionProperty(label=some_key_1, value=Title(text=some_key_1))), \n    //                value=SingleValue(name=value, type=Text, value=NotionProperty(label=some_value_1, value=Text(text=some_value_1)))\n    //            }\n    //            metaInfo=MetaInfo(lastEditedBy=d6a033eb-82bb-49dd-975c-82ccb739f30e, lastEditedTime=1606350180000, createdBy=d6a033eb-82bb-49dd-975c-82ccb739f30e, createdTime=1606350145225))\n    //    ], \n    //    schema={\n    //        key=Title(name=key, type=Title)\n    //        checked=Checkbox(name=checked, type=Checkbox), \n    //        value=Text(name=value, type=Text)\n    //     }\n    // )\n\n    // now the json is much more readable!\n    println(json.encodeToString(table))\n\n    // works like a charm as well\n    println(json.decodeFromString\u003cNotionTable\u003e(json.encodeToString(table)))\n    \n    // or even better:\n    val simpleJson: List\u003cJsonElement\u003e? = table.simpleJsonRows(json)\n    \n    println(simpleJson)\n    // Output:\n    // [{\"checked\":true,\"value\":\"some_value_0\",\"key\":\"some_key_0\"},{\"value\":\"some_value_1\",\"key\":\"some_key_1\"}]\n    \n    // map to your model:\n    val yourModels = simpleJson?.map { json.decodeFromJsonElement\u003cSomeItem\u003e(it) }\n    \n    println(yourModels)\n    // Output:\n    // [SomeItem(key=some_key_0, value=some_value_0, checked=true), SomeItem(key=some_key_1, value=some_value_1, checked=false)]\n}\n\n@Serializable\ndata class SomeItem(\n    val key: String,\n    val value: String,\n    val checked: Boolean = false\n)\n```\n\nSupported types of columns:\n- `Title`, `Text`, `Number`, `Checkbox`, `Select`, `MultiSelect`;\n- `Person`, `Link`, `File`, `Email`, `PhoneNumber`\n- `Date`\n\nUnfortunately, Notion API is too dynamically typed to easy cover all the cases for the column types.\nAlso, some types, such as `Created by`, don't have the property value, but you can access it from the row meta info.\nThey added just because otherwise JSON deserialization will fail (they will appear only in row `schema`).\n\n**Note**:\n- sometimes Notion can return almost empty response, so just make a request again;\n- after several requests, auth endpoint will throw 429, limitations are unknown.\n\nActually the main purpose of the library is to retrieve the data from the Notion database (collection).\nYou can only authenticate and read, but not write or listen for the updates.\nIt uses the private APIs, reverse engineering helped here, so it may sometimes fail, or be even banned when Notion will release their paid APIs.\nUnfortunately it is the only way to retrieve any info from Notion so far.\nUse it at your own risk. For educational purposes only.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotionsdk%2Fnotion-sdk-kotlin-old","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnotionsdk%2Fnotion-sdk-kotlin-old","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnotionsdk%2Fnotion-sdk-kotlin-old/lists"}