From a2ab535256a80620f5ed3102d9ddea2c4dea6fed Mon Sep 17 00:00:00 2001 From: n0one Date: Sat, 6 Sep 2025 03:37:07 +0300 Subject: [PATCH 1/2] Add README.MD --- README.MD | 238 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 238 insertions(+) create mode 100644 README.MD diff --git a/README.MD b/README.MD new file mode 100644 index 0000000..c52d975 --- /dev/null +++ b/README.MD @@ -0,0 +1,238 @@ +# Habr article API + +This is a simple API that can be deployed on your server to access habr.com's articles content, as well as keeping a record of articles and their ratings which you can manage by connecting to corresponding endpoints. + +From here on on out we will call a pair "article_url" - "rating" an **entry**. + +## API Reference + + + + +### Ping + +```http + GET /api/ping +``` + +A basic ping endpoint. + +#### Response on success + +`application/json` +```json +{ + "message": "pong" +} +``` + + + +### See current entries + + +```http + GET /api/rates +``` + +Returns all entries in the PostreSQL DB. + +#### Response on success + +`application/json` +```json +{ + "article_url_1": rating(0 or 1), + "article_url_2": rating(0 or 1), + ... +} +``` + + + +### Make a new entry + + +```http + POST /api/article/rate +``` + +Save a new entry to the DB. + +#### Request body + +`application/json` +```json +{ + "url": {article_url}, + "rating": {integer, 0 or 1} +} +``` + + +#### Response on success + +`application/json` +```json +{ + "message": "success", + "url": "{article_url}", + "rating": {integer, 0 or 1} +} +``` + + + +### Delete an entry + + +```http + POST /api/article/remove_rate +``` + +Delete an existing entry from the DB. + +#### Request body + +`application/json` +```json +{ + "url": "{article_url}" +} +``` + + +#### Response on success + +`application/json` +```json +{ + "message": "success" +} +``` + + + + + +### Get article html + +```http + POST /api/article/api/article/get/html +``` + +Get hmtl of a desired habr article body encoded in base64. + +#### Request body + +`application/json` +```json +{ + "url": "{article_url}" +} +``` + +#### Response on success + +`text/plain` +``` +{article_url} + +{b64 encoded html} +``` + + + + + +### Get article MD + +```http + POST /api/article/api/article/get/md +``` + +Get md of a desired habr article body encoded in base64. + +#### Request body + +`application/json` +```json +{ + "url": "{article_url}" +} +``` + +#### Response on success + +`text/plain` +``` +{article_url} + +{b64 encoded md} +``` + + + + + +### Get html of N articles from habr.com/feed + +```http + POST /api/article/api/articles/get/html +``` + +Get html bodies of N last articles from [habr.com/feed](habr.com/feed) + +#### Request body + +`application/json` +```json +{ + "amount": {articles_amount} +} +``` + +#### Response on success + +`application/json` +```json +{ + "{article_url_1}": "{b64_encoded_html}", + "{article_url_2}": "{b64_encoded_html}", + ... + "{article_url_n}": "{b64_encoded_html}" +} +``` + + + + + +### Get MD of N articles from habr.com/feed + +```http + POST /api/article/api/articles/get/html +``` + +Get MD of N last articles from [habr.com/feed](habr.com/feed) + +#### Request body + +`application/json` +```json +{ + "amount": {articles_amount} +} +``` + +#### Response on success + +`application/json` +```json +{ + "{article_url_1}": "{b64_encoded_md}", + "{article_url_2}": "{b64_encoded_md}", + ... + "{article_url_n}": "{b64_encoded_md}" +} +``` \ No newline at end of file From 2ecf7ae56d24e378d83eb204403e96308e931731 Mon Sep 17 00:00:00 2001 From: n0one Date: Sat, 6 Sep 2025 03:37:55 +0300 Subject: [PATCH 2/2] Update README.MD --- README.MD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.MD b/README.MD index c52d975..4de1811 100644 --- a/README.MD +++ b/README.MD @@ -211,7 +211,7 @@ Get html bodies of N last articles from [habr.com/feed](habr.com/feed) ### Get MD of N articles from habr.com/feed ```http - POST /api/article/api/articles/get/html + POST /api/article/api/articles/get/md ``` Get MD of N last articles from [habr.com/feed](habr.com/feed)