> For the complete documentation index, see [llms.txt](https://skygl.gitbook.io/devlog/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://skygl.gitbook.io/devlog/post.md).

# Post

## Get List of Posts

<mark style="color:blue;">`GET`</mark> `https://api.devlog.today/posts`

This endpoint allows you to get posts that meet the corresponding condition.

#### Query Parameters

| Name        | Type    | Description                                                         |
| ----------- | ------- | ------------------------------------------------------------------- |
| \_start     | integer | Starting index of posts. (must be positive or 0)                    |
| \_end       | integer | Ending index of posts. (must be positive and bigger than "\_start") |
| \_sort      | string  | Field name which posts will be sorted by.                           |
| \_order     | string  | Sort Order. (ASC or DESC)                                           |
| score       | string  | Posts received the corresponding score.                             |
| start\_date | string  | Start date at which posts published.                                |
| end\_date   | string  | End date at which posts published.                                  |
| unscored    | boolean | Whether posts was unscored or not.                                  |
| url         | string  | Words included in URL.                                              |

{% tabs %}
{% tab title="200 Response if a server find posts successfully." %}

```javascript
[    
    {
        "_id": "507f1f77bcf86cd799439011",
        "tags": [
            "tag1",
            "tag2"
        ],
        "url": "https://devlog.today/posts/123",
        "title": "Post Title",
        "description": "Post Description",
        "imageUrl": "https://devlog.today/logo.png",
        "published_at": "2020-07-05T07:53:21.000Z",
        "created_at": "2020-07-6T03:16:12.711Z",
        "__v": 0,
        "score": 7,
        "id": "507f1f77bcf86cd799439011"
    },
    
    // ... more Posts
]
```

{% endtab %}

{% tab title="422 Response if query parameters are not valid format." %}

```
{
    "errors": [
        {
            "value": "0",
            "msg": "must be less than end",
            "param": "_start",
            "location": "query"
        }
    ]
}
```

{% endtab %}

{% tab title="500 Response if unexpected server error or database error occurs." %}

```
```

{% endtab %}
{% endtabs %}

## Get A Post With Id

<mark style="color:blue;">`GET`</mark> `https://api.devlog.today/posts/:id`

This endpoint allows you to get a post with given id.

#### Path Parameters

| Name | Type   | Description                        |
| ---- | ------ | ---------------------------------- |
| id   | string | An ObjectId of a post to be found. |

#### Headers

| Name          | Type   | Description                       |
| ------------- | ------ | --------------------------------- |
| authorization | string | Json Web Token certified as admin |

{% tabs %}
{% tab title="200 Response if post with the corresponding id exists." %}

```javascript
{
    "_id": "507f1f77bcf86cd799439011",
    "tags": [
        "tag1",
        "tag2"
    ],
    "url": "https://devlog.today/posts/123",
    "title": "Post Title",
    "description": "Post Description",
    "imageUrl": "https://devlog.today/logo.png",
    "published_at": "2020-07-05T07:53:21.000Z",
    "created_at": "2020-07-6T03:16:12.711Z",
    "__v": 0,
    "score": 7,
    "id": "507f1f77bcf86cd799439011"
}
```

{% endtab %}

{% tab title="404 Response if post with the corresponding id doesn't exist." %}

```
```

{% endtab %}

{% tab title="422 Given id was not valid mongoDB ObjectId format." %}

```
{
    "errors": [
        {
            "value": "abcd",
            "msg": "must be mongoId",
            "param": "id",
            "location": "params"
        }
    ]
}
```

{% endtab %}

{% tab title="500 Response if unexpected server error or database error occurs." %}

```
```

{% endtab %}
{% endtabs %}

## Score Post

<mark style="color:orange;">`PUT`</mark> `https://api.devlog.today/posts/:id`

This endpoint allows you to get existence of blog or blog request with given URL.

#### Headers

| Name          | Type   | Description                       |
| ------------- | ------ | --------------------------------- |
| authorization | string | Json Web Token certified as admin |

#### Request Body

| Name  | Type    | Description                                       |
| ----- | ------- | ------------------------------------------------- |
| id    | string  | An ObjectId of a post to be scored                |
| score | integer | Score to be given to the post. ( range : 1 - 10 ) |

{% tabs %}
{% tab title="200 Response if Post updated successfully." %}

```javascript
{
    "id": "5f0145fbcfd592d13dfa0b4f",
    "previousData": {
        "tags": [
            "tag1",
            "tag2"
        ],
        "_id": "5f0145fbcfd592d13dfa0b4f",
        "url": "https://devlog.today/posts/123",
        "title": "Post Title",
        "description": "Post Description",
        "imageUrl": "https://devlog.today/logo.png",
        "published_at": "2020-07-05T07:53:21.000Z",
        "created_at": "2020-07-6T03:16:12.711Z",
        "__v": 0,
        "score": 7
    },
    "data": {
        "tags": [
            "centos6",
            "Linux"
        ],
        "_id": "5f0145fbcfd592d13dfa0b4f",
        "url": "https://devlog.today/posts/123",
        "title": "Post Title",
        "description": "Post Description",
        "imageUrl": "https://devlog.today/logo.png",
        "published_at": "2020-07-05T07:53:21.000Z",
        "created_at": "2020-07-6T03:16:12.711Z",
        "__v": 0,
        "score": 6
    }
}
```

{% endtab %}

{% tab title="404 Response if the post with given Id doesn't exist." %}

```
```

{% endtab %}

{% tab title="422 Given parameters were not valid format." %}

```
{
    "errors": [
        {
            "msg": "must be mongoId",
            "param": "id",
            "location": "body"
        },
        {
            "value": 11,
            "msg": "must be between 1 and 10",
            "param": "score",
            "location": "body"
        }
    ]
}
```

{% endtab %}

{% tab title="500 Response if unexpected server error or database error occurs." %}

```
```

{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://skygl.gitbook.io/devlog/post.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
