Skip to content

Texts

httpkom.texts

texts_get(text_no) async

Get a text.

Note: The body will only be included in the response if the content type is text.

Request:

GET /<server_id>/texts/19680717 HTTP/1.0

Responses:

Text exists:

HTTP/1.0 200 OK

{
  "body": "räksmörgås",
  "recipient_list": [
    {
      "recpt": {
        "conf_no": 14506
        "name": "Oskars Testperson",
      },
      "type": "to",
      "loc_no": 29,
    }
  ],
  "author": {
    "pers_no": 14506,
    "pers_name": "Oskars Testperson"
  },
  "creation_time": "2013-11-30T15:58:06Z",
  "comment_in_list": [],
  "content_type": "text/x-kom-basic",
  "text_no": 19680717,
  "comment_to_list": [],
  "subject": "jaha"
}

Text does not exist:

HTTP/1.0 404 NOT FOUND

{ TODO: error stuff }

Example:

curl -v -X GET -H "Content-Type: application/json" \
     "http://localhost:5001/lyskom/texts/19680717"

textstats_get(text_no) async

Get text stat (metadata without body/subject).

Same shape as GET /texts/ but without subject, body, and content_type. Useful for comment-tree discovery without fetching full text bodies.

Request:

GET /<server_id>/textstats/19680717 HTTP/1.1

textstats_batch() async

Get text stats for multiple texts in one request.

Request:

POST /<server_id>/textstats HTTP/1.1

{
  "text_nos": [100, 101, 102]
}

Response:

HTTP/1.1 200 OK

{
  "text_stats": {
    "100": { ... },
    "101": { ... },
    "102": null
  }
}

Missing texts are returned as null. Maximum 100 text numbers per request.

texts_get_body(text_no) async

Get the body of text, with the content type of the body set in the HTTP header. Useful for creating img-tags in HTML and specifying this URL as source.

If the content type is text, the text will be recoded to UTF-8. For other types, the content type will be left untouched.

Request:

GET /<server_id>/texts/19680717/body HTTP/1.0

Responses:

Text exists:

HTTP/1.0 200 OK
Content-Type: text/x-kom-basic; charset=utf-8

räksmörgås

Text does not exist:

HTTP/1.0 404 NOT FOUND

{ TODO: error stuff }

Example:

curl -v -X GET -H "Content-Type: application/json" \
     "http://localhost:5001/lyskom/texts/19680717/body"

texts_create() async

Create a text.

Request:

POST /<server_id>/texts/ HTTP/1.0

{
  "body": "räksmörgås",
  "subject": "jaha",
  "recipient_list": [ { "type": "to", "recpt": { "conf_no": 14506 } } ],
  "content_type": "text/x-kom-basic",
  "comment_to_list": [ { "type": "footnote", "text_no": 19675793 } ]
}

Responses:

Text was created:

HTTP/1.0 201 Created
Location: http://localhost:5001/<server_id>/texts/19724960

{
  "text_no": 19724960,
}

Example text:

curl -v -X POST -H "Content-Type: application/json" \
     -d '{ "body": "räksmörgås", \
           "subject": "jaha", \
           "recipient_list": [ { "recpt": { "conf_no": 14506 }, "type": "to" } ], \
           "content_type": "text/x-kom-basic", \
           "comment_to_list": [ { "type": "footnote", "text_no": 19675793 } ] }' \
     "http://localhost:5001/lyskom/texts/"

Example image:

curl -v -X POST -H "Content-Type: application/json" \
     -d '{ "body": "<base64>", \
           "subject": "jaha", \
           "recipient_list": [ { "recpt": { "conf_no": 14506 }, "type": "to" } ], \
           "content_type": "image/jpeg", \
           "content_encoding": "base64", \
           "comment_to_list": [ { "type": "footnote", "text_no": 19675793 } ] }' \
     "http://localhost:5001/lyskom/texts/"

texts_get_marks() async

Get the list of marked texts.

Request:

GET /<server_id>/texts/marks/ HTTP/1.1

Response:

HTTP/1.1 200 OK

{
  "marks": [
    { "text_no": 4711, "type": 100 },
    { "text_no": 4999999, "type": 101 },
  ]
}

Example:

curl -v -X GET -H "Content-Type: application/json" \
     "http://localhost:5001/lyskom/texts/marks/"

texts_put_mark(text_no) async

Mark a text.

Request:

PUT /<server_id>/texts/<text_no>/mark HTTP/1.1

{
  "type": 100
}

Response:

Success:

HTTP/1.1 201 Created

Example:

curl -v -X PUT -H "Content-Type: application/json" \
     -d { "type": 100 } \
     "http://localhost:5001/lyskom/texts/4711/mark"

texts_delete_mark(text_no) async

Unmark a text.

Request:

DELETE /<server_id>/texts/<text_no>/mark HTTP/1.1

Response:

Success:

HTTP/1.1 204 OK

Example:

curl -v -X DELETE "http://localhost:5001/lyskom/texts/4711/mark"

texts_put_read_marking(text_no) async

Mark a text as read in all recipient conferences.

Request:

PUT /<server_id>/texts/<int:text_no>/read-marking HTTP/1.0

Responses:

Text was marked as read:

HTTP/1.0 201 Created

Example:

curl -v -X PUT "http://localhost:5001/lyskom/texts/19680717/read-marking"

texts_delete_read_marking(text_no) async

Mark a text as unread in all recipient conferences.

Request:

DELETE /<server_id>/texts/<int:text_no>/read-marking HTTP/1.0

Responses:

Text was marked as unread:

HTTP/1.0 204 NO CONTENT

Example:

curl -v -X DELETE "http://localhost:5001/lyskom/texts/19680717/read-marking"