> 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/blog.md).

# Blog

## Create Blog

<mark style="color:green;">`POST`</mark> `https://api.devlog.today/blogs`

This endpoint allows you to create new blog.

#### Headers

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

#### Request Body

| Name     | Type   | Description                        |
| -------- | ------ | ---------------------------------- |
| url      | string | URL of blog will be created.       |
| feed.url | string | Feed URL of blog will be created.  |
| feed.tag | string | Tag selector of post will be added |

{% tabs %}
{% tab title="200 Response if Blog created successfully." %}

```
{
    "feed": {
        "url": "https://devlog.today",
        "tag": ""
    },
    "updated_at": "2020-07-23T07:41:48.073Z",
    "_id": "5f193f3cf8504628489bef37",
    "url": "https://devlog.today",
    "created_at": "2020-07-23T07:41:48.072Z",
    "__v": 0,
    "id": "5f193f3cf8504628489bef37"
}
```

{% endtab %}

{% tab title="409 Response if Blog with given URL exists already." %}

```
```

{% endtab %}

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

```
{
    "errors": [
        {
            "value": "abcd",
            "msg": "must be url",
            "param": "feed.url",
            "location": "body"
        }
    ]
}
```

{% endtab %}

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

```
```

{% endtab %}
{% endtabs %}

## Get List of Blogs

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

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

#### Query Parameters

| Name        | Type    | Description                                                         |
| ----------- | ------- | ------------------------------------------------------------------- |
| \_start     | integer | Starting index of blogs. (must be positive or 0)                    |
| \_end       | integer | Ending index of blogs. (must be positive and bigger than "\_start") |
| \_sort      | string  | Field name which blogs will be sorted by.                           |
| \_order     | string  | Sort Order. (ASC or DESC)                                           |
| start\_date | string  | Start date at which blogs created.                                  |
| end\_date   | string  | End date at which blogs created.                                    |
| url         | string  | Words included in URL.                                              |

#### Headers

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

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

```javascript
[
    {
        "_id": "5e95be06b3e7301d1f99eabc",
        "feed": {
            "url": "https://devlog.today/rss",
            "tag": ".tags > a"
        },
        "updated_at": "2020-07-07T06:54:02.695Z",
        "url": "https://devlog.today",
        "created_at": "2020-07-06T13:43:34.202Z",
        "id": "5e95be06b3e7301d1f99eabc"
    },
    
    // ... more Blogss
]
```

{% endtab %}

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

```javascript
{
    "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 Blog With Id

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

This endpoint allows you to get a blog with id.

#### Path Parameters

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

#### Headers

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

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

```javascript
{
    "_id": "5e95be06b3e7301d1f99eabc",
    "feed": {
        "url": "https://devlog.today/rss",
        "tag": ".tags > a"
    },
    "updated_at": "2020-07-07T06:54:02.695Z",
    "url": "https://devlog.today",
    "created_at": "2020-07-06T13:43:34.202Z",
    "id": "5e95be06b3e7301d1f99eabc"
}
```

{% endtab %}

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

```
```

{% endtab %}

{% tab title="422 Given parameter is not valid format." %}

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

{% endtab %}

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

```
```

{% endtab %}
{% endtabs %}

## Update Blog

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

This endpoint allows you to update a blog.

#### Headers

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

#### Request Body

| Name     | Type   | Description                                |
| -------- | ------ | ------------------------------------------ |
| \_id     | string | ObjectId of a blog to be updated.          |
| url      | string | URL of a blog to be updated.               |
| feed.url | string | Feed URL of a blog  to be updated.         |
| feed.tag | string | Tag selector of a blog post to be updated. |

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

```javascript
{
    "id": "5e95be06b3e7301d1f99eabc",
    "previousData": {
        "_id": "5e95be06b3e7301d1f99eabc",
        "feed": {
            "url": "https://devlog.today/rss",
            "tag": ".tags > a"
        },
        "updated_at": "2020-07-07T06:54:02.695Z",
        "url": "https://devlog.today",
        "created_at": "2020-07-06T13:43:34.202Z",
    },
    "data": {
        "_id": "5e95be06b3e7301d1f99eabc",
        "feed": {
            "url": "https://devlog.today/rss",
            "tag": ".tags-content > a"
        },
        "updated_at": "2020-07-07T06:54:02.695Z",
        "url": "https://devlog.today",
        "created_at": "2020-07-06T13:43:34.202Z",
    }
}
```

{% endtab %}

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

```
```

{% endtab %}

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

```
{
    "errors": [
        {
            "value": "abc",
            "msg": "must be url",
            "param": "feed.url",
            "location": "body"
        }
    ]
}
```

{% endtab %}

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

```
```

{% endtab %}
{% endtabs %}

## Delete Blog

<mark style="color:red;">`DELETE`</mark> `https://api.devlog.today/blogs/:id`

#### Path Parameters

| Name | Type   | Description                       |
| ---- | ------ | --------------------------------- |
| id   | string | ObjectId of a blog to be deleted. |

#### Headers

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

{% tabs %}
{% tab title="200 Response if blog with given Id deleted successfully." %}

```javascript
{
    "feed": {
        "url": "https://v2.velog.io/rss/hygoogi",
        "tag": ".head-wrapper > div > a1"
    },
    "updated_at": "2020-07-23T07:01:39.332Z",
    "_id": "5e95be06b3e7301d1f99ec41",
    "url": "https://velog.io/@hygoogi",
    "created_at": "2020-04-14T13:43:34.202Z"
}
```

{% endtab %}

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

```
```

{% endtab %}

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

```javascript
{
    "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 %}


---

# 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/blog.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.
