fixed API

This commit is contained in:
boxi committed 2026-05-15 20:39:49 +02:00
1 parent af0d8b77a5
commit d74e243cf7
5 files changed
+45 -17

No files matched your search

+18 -7
View File
@@ -1,21 +1,22 @@
### Get Spaces
GET http://localhost:31009/v1/spaces
Authorization: Bearer {{apiKey}}
Anytype-Version: 2025-11-08
### Get Types
GET http://localhost:31009/v1/spaces/{{spaceId}}/types
Authorization: Bearer {{apiKey}}
Anytype-Version: 0.1
Anytype-Version: 2025-11-08
### Get Type
GET http://localhost:31009/v1/spaces/{{spaceId}}/types/{{taskTypeId}}
Authorization: Bearer {{apiKey}}
Anytype-Version: 0.1
Anytype-Version: 2025-11-08
### Get objects of type
POST http://localhost:31009/v1/spaces/{{spaceId}}/search?type=project
Authorization: Bearer {{apiKey}}
Anytype-Version: 0.1
Anytype-Version: 2025-11-08
Content-Type: application/json
{
@@ -23,19 +24,29 @@ Content-Type: application/json
}
### Get Property
GET http://localhost:31009/v1/spaces/{{spaceId}}/properties/{{priorityPropertyId}}
GET http://localhost:31009/v1/spaces/{{spaceId}}/properties/{{priorityPropertyId}}/tags
Authorization: Bearer {{apiKey}}
Anytype-Version: 0.1
Anytype-Version: 2025-11-08
### Get Property Values Priority
GET http://localhost:31009/v1/spaces/{{spaceId}}/properties/{{priorityPropertyId}}/tags
Authorization: Bearer {{apiKey}}
Anytype-Version: 2025-11-08
### Get Property Values Project
GET http://localhost:31009/v1/spaces/{{spaceId}}/properties/{{projectPropertyId}}/tags
Authorization: Bearer {{apiKey}}
Anytype-Version: 2025-11-08
### Get Property Tags
GET http://localhost:31009/v1/spaces/{{spaceId}}/properties/{{priorityPropertyId}}/tags
Authorization: Bearer {{apiKey}}
Anytype-Version: 0.1
Anytype-Version: 2025-11-08
### Get Templates
GET http://localhost:31009/v1/spaces/{{spaceId}}/types/{{taskTypeId}}/templates
Authorization: Bearer {{apiKey}}
Anytype-Version: 0.1
Anytype-Version: 2025-11-08
### Create Task
POST http://localhost:31009/v1/spaces/{{spaceId}}/objects
@@ -6,6 +6,7 @@ import io.ktor.client.call.*
import io.ktor.client.engine.cio.*
import io.ktor.client.plugins.*
import io.ktor.client.plugins.contentnegotiation.*
import io.ktor.client.plugins.defaultRequest
import io.ktor.client.request.*
import io.ktor.client.statement.*
import io.ktor.http.*
@@ -32,7 +33,10 @@ class AnyTypeApi(
private val http = HttpClient(CIO) {
install(ContentNegotiation) {
json(Json { ignoreUnknownKeys = true })
json(Json { ignoreUnknownKeys = true; explicitNulls = false })
}
defaultRequest {
header("Anytype-Version", "2025-11-08")
}
}.also { client ->
client.plugin(HttpSend).intercept { request ->
@@ -62,7 +66,6 @@ class AnyTypeApi(
suspend fun getSpaces(): Result<List<Space>> =
runCatching {
val response = http.get("$baseUrl/v1/spaces") {
header("Anytype-Version", "0.1")
bearerAuth(apiKey)
}
response.body<SpacesResponse>().data
@@ -71,7 +74,6 @@ class AnyTypeApi(
suspend fun getTypes(): Result<List<ObjectType>> =
runCatching {
val response = http.get("$baseUrl/v1/spaces/$spaceId/types") {
header("Anytype-Version", "0.1")
bearerAuth(apiKey)
}
response.body<TypesResponse>().data
@@ -81,7 +83,6 @@ class AnyTypeApi(
runCatching {
val response = http.post("$baseUrl/v1/spaces/$spaceId/search") {
contentType(ContentType.Application.Json)
header("Anytype-Version", "0.1")
bearerAuth(apiKey)
setBody(mapOf("types" to listOf(typeKey)))
}
@@ -91,7 +92,6 @@ class AnyTypeApi(
suspend fun getTags(propertyId: String): Result<List<Tag>> =
runCatching {
val response = http.get("$baseUrl/v1/spaces/$spaceId/properties/$propertyId/tags") {
header("Anytype-Version", "2025-11-08")
bearerAuth(apiKey)
}
response.body<TagsResponse>().data
@@ -100,7 +100,6 @@ class AnyTypeApi(
suspend fun getTemplates(typeId: String): Result<List<Template>> =
runCatching {
val response = http.get("$baseUrl/v1/spaces/$spaceId/types/$typeId/templates") {
header("Anytype-Version", "0.1")
bearerAuth(apiKey)
}
response.body<TemplatesResponse>().data
@@ -108,7 +107,7 @@ class AnyTypeApi(
suspend fun createObject(
title: String,
details: String = "",
details: String? = null,
typeKey: String,
templateId: String? = null,
properties: List<JsonElement> = emptyList(),
@@ -116,12 +115,11 @@ class AnyTypeApi(
runCatching {
val response = http.post("$baseUrl/v1/spaces/$spaceId/objects") {
contentType(ContentType.Application.Json)
header("Anytype-Version", "0.1")
bearerAuth(apiKey)
setBody(
CreateObjectRequest(
name = title,
body = details,
body = details?.takeIf { it.isNotBlank() },
typeKey = typeKey,
templateId = templateId,
properties = properties,
@@ -7,7 +7,7 @@ import kotlinx.serialization.json.JsonElement
@Serializable
data class CreateObjectRequest(
val name: String,
val body: String,
val body: String? = null,
@SerialName("type_key") val typeKey: String,
@SerialName("template_id") val templateId: String? = null,
val properties: List<JsonElement> = emptyList(),
@@ -0,0 +1,11 @@
package ch.ergon.anytask.api.dto
import kotlinx.serialization.Serializable
@Serializable
data class Tag(
val id: String,
val key: String = "",
val name: String,
val color: String = "",
)
@@ -0,0 +1,8 @@
package ch.ergon.anytask.api.dto
import kotlinx.serialization.Serializable
@Serializable
data class TagsResponse(
val data: List<Tag>,
)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.