Menu

Kozeki REST API

You can use simple REST API to read/write any values into key-value stores.

Endpoint

The base domain for the API is kozeki.natsuneko.com, and the API is versioned by the /v prefix. The current API version is 1 and you can access all APs at https://kozeki.natsuneko.com/v1.

Authentication

All API endpoints are requires the authentication by Authorization header with access token. Bearer authentication is performed using the Authorization header for authentication, and the value specified at the time of creation is used for the token. If your access token is leaked for some reason, you can revoke it by sending a new access token to the account update API.

Generate an access token according to the following format:

/^kz-[a-z0-9_-]{32}$/;

Example request:

GET https://kozeki.natsuneko.com/v1/users/example/notes/TYO.3663
Content-Type: application/json
Authorization: Bearer kz-a15a862f5cf7415998211991675b868e

Rate Limit

The rate limit is 2,500 requests per IP and user per hour. Refer to the X-RateLimit-Limit, X-RateLimit-Remaining, and X-RateLimit-Reset response headers to know when your account approaching to the rate limit, and reset to rate limit. When your account reached to rate limit, your API return a following response:

{
  "status": 429,
  "message": "too many requests"
}

Rate-Limit algorithm uses sliding-window.

Limits:

tiernamedescription
Tier 1Thanks Platinum10,000 req/user/hour
Tier 2Thanks Gold7,500 req/user/hour
Tier 3Thanks Silver5,000 req/user/hour
Tier 4Thanks Bronze2,500 req/user/hour
Tier 5Normal1,000 req/user/hour

Account

POST /v1/users

create a new user

Request Body

nametyperequireddescription
usernamestringrequiredan unique username of this service, rule: [a-z][a-z0-9-]{1,32}
access*token:stringrequiredan access token used to authenticate, rule: kz-[a-z0-9*-]{32}
agree_to_terms_of_servicebooleanrequiredset to true whether you agree to the terms of service
thanks_codestringoptionalset thanks-code when you have it. if it is a valid thanks-code, some limits wll be relaxed. check to relaxing limits

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
409Conflictthis error occurs when unable to use your requested username

PATCH /v1/users/:username

update user data

Request Uri

nametyperequireddescription
usernamestringrequireda username

Request Body

nametyperequireddescription
access_tokenstringoptionala renewed access token used to authenticate, rule: kz-[a-z0-1_-]{32}
thanks_codestringoptionalset thanks-code when you have it. if it is a valid thanks-code, some limits wll be relaxed. check to relaxing limits

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure

DELETE /v1/users/:username

delete a user

Request Uri

nametyperequireddescription
usernamestringrequireda username

Request Body

none

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure

Note

POST /v1/users/:username/notes

create a new post

Request Uri

nametyperequireddescription
usernamestringrequireda username

Request Body

nametyperequireddescription
idstringrequiredan id for identifying the note. rule: [a-z][a-z0-9-_.]{1,32}
namestringoptionalname of the note, default: untitled
contentstringrequiredcontent of the note, up to 10kb
restrictionstringoptionalone of public or private, default: private
transactionbooleanoptionalif set to true, updating the note requires a nonce based on the previous content.

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure
409Conflictthis error occurs when unable to create the note because id already exists

GET /v1/users/:username/notes/:note

get a specified post

Request Uri

nametyperequireddescription
usernamestringrequireda username
notestringrequirenote id

Request Body

none

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message
titlestringrequired
contentstringrequired

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure

PATCH /v1/users/:username/notes/:note

update the note metadata

Request Uri

nametyperequireddescription
usernamestringrequireda username
notestringrequirenote id

Request Body

nametyperequireddescription
restrictionstringoptionalone of public or private, default: private
transactionbooleanoptionalif set to true, updating the note requires a nonce based on the previous content.

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure

PUT /v1/users/:username/notes

update a specify post

Request Uri

nametyperequireddescription
usernamestringrequireda username
notestringrequirenote id

Request Body

nametyperequireddescription
namestringoptionalname of the note, default: untitled
contentstringrequiredcontent of the note, up to 10kb
noncestringoptionalset to nonce when transaction is enabled

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure
409Conflictthis error occurs when unable to update the note because transaction is enabled and nonce is incorrect

POST /v1/users/:username/notes/:note/publish

publish the specified note

Request Uri

nametyperequireddescription
usernamestringrequireda username
notestringrequirenote id

Request Body

none

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message
secretstringrequiredreadonly secret for specified note

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure

DELETE /v1/users/:username/notes/:note

delete a note

Request Uri

nametyperequireddescription
usernamestringrequireda username
notestringrequirenote id

Request Body

none

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure

GET /v1/publications/:id

get the specified publication

Request Uri

nametyperequireddescription
idstringrequirepublication id

Request Body

none

Response

nametyperequireddescription
statusnumberrequiredHTTP status code
messagestringrequiredresponse message
namestringrequired
contentstringrequired

HTTP Response Code

codemessagedescription
200OK
400Bad Requestthis error occurs when there is some mistakes in your request.
403Forbiddenthis error occurs when unable to process your requests due to its terms or specifications
404Not Foundthis error occurs when unable to find requested uri or authenticated failure