# Articles

API for managing articles

## List Articles

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/articles/:app_id`

This endpoint **returns** a list of all `articles` that belong to the magazine

#### Path Parameters

| Name    | Type   | Description                                     |
| ------- | ------ | ----------------------------------------------- |
| app\_id | String | App ID (Publication) to scope this request for. |

#### Query Parameters

| Name       | Type    | Description                              |
| ---------- | ------- | ---------------------------------------- |
| order\_by  | Symbol  | Field to sort results by                 |
| order\_dir | Symbol  | Direction (asc, desc) to sort results by |
| issue\_id  | Integer |                                          |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "id": 1234,
  "title": "Welcome to MagLoft",
  "info": null,
  "html": null,
  "assets": null,
  "cover": null,
  "date": null,
  "unlock_type": "free",
  "categories": [
    "Sports",
    "Business",
    "Politics"
  ],
  "category_ids": [
    1,
    2,
    3
  ],
  "publication_id": null,
  "issue_id": null,
  "position": null,
  "visible": true,
  "rss_feed_id": null,
  "source": null
}
```

{% endtab %}
{% endtabs %}

## Retrieve paginated list of articles

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/articles/:app_id/page/:page`

This endpoint **returns** a page list of all `articles` that belong to the magazine

#### Path Parameters

| Name    | Type    | Description                                     |
| ------- | ------- | ----------------------------------------------- |
| app\_id | String  | App ID (Publication) to scope this request for. |
| page    | Integer | The page number to list                         |

#### Query Parameters

| Name       | Type    | Description                              |
| ---------- | ------- | ---------------------------------------- |
| per\_page  | Integer | Number of items to show per page         |
| order\_by  | Symbol  | Field to sort results by                 |
| order\_dir | Symbol  | Direction (asc, desc) to sort results by |
| filter     | String  | Text filter to search results by         |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "total": 1,
  "page": 1,
  "records": [
    {
      "id": 1234,
      "title": "Welcome to MagLoft",
      "info": null,
      "hpub": null,
      "source_file": null,
      "source": "typeloft",
      "unlock_type": "free",
      "hide_locked": false,
      "categories": [
        "Sports",
        "Business",
        "Politics"
      ],
      "category_ids": [
        1,
        2,
        3
      ],
      "classifications": [
        "Sports",
        "Business",
        "Politics"
      ],
      "classification_ids": [
        1,
        2,
        3
      ],
      "product_id": "purchase.issue_123456789",
      "product_id_apple": null,
      "product_id_google": null,
      "product_id_amazon": null,
      "screen_type": "issue",
      "publication_id": null,
      "coupon_code": null,
      "dirty": false,
      "user_id": null,
      "custom_stylesheet": null,
      "custom_data": null,
      "price_tier": null,
      "cover": null,
      "generator": "pdfix"
    }
  ]
}
```

{% endtab %}
{% endtabs %}

## Get Article

<mark style="color:blue;">`GET`</mark> `https://www.magloft.com/api/portal/v1/articles/:app_id/:id`

This endpoint **returns** a specific `article` by `id`

#### Path Parameters

| Name    | Type    | Description                                     |
| ------- | ------- | ----------------------------------------------- |
| app\_id | String  | App ID (Publication) to scope this request for. |
| id      | Integer | Article ID                                      |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "id": 1234,
  "title": "Welcome to MagLoft",
  "info": null,
  "html": null,
  "assets": null,
  "cover": null,
  "date": null,
  "unlock_type": "free",
  "categories": [
    "Sports",
    "Business",
    "Politics"
  ],
  "category_ids": [
    1,
    2,
    3
  ],
  "publication_id": null,
  "issue_id": null,
  "position": null,
  "visible": true,
  "rss_feed_id": null,
  "source": null
}
```

{% endtab %}
{% endtabs %}

## Create an Article

<mark style="color:green;">`POST`</mark> `https://www.magloft.com/api/portal/v1/articles/:app_id`

This endpoint **creates** a new `article` and **returns** the saved `article`

#### Path Parameters

| Name    | Type   | Description                                     |
| ------- | ------ | ----------------------------------------------- |
| app\_id | String | App ID (Publication) to scope this request for. |

#### Request Body

| Name          | Type    | Description                                   |
| ------------- | ------- | --------------------------------------------- |
| title         | String  | Article Title                                 |
| info          | String  | Article Description                           |
| html          | String  | Article HTML                                  |
| date          | String  | Article Publish Date                          |
| cover         | String  | Article Cover                                 |
| category\_ids | Array   | Article category IDs                          |
| issue\_id     | Integer | Issue ID                                      |
| unlock\_type  | String  | Unlock Type                                   |
| position      | Integer | Order Position of the Article within an Issue |
| source        | String  | Article type                                  |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "id": 1234,
  "title": "Welcome to MagLoft",
  "info": null,
  "html": null,
  "assets": null,
  "cover": null,
  "date": null,
  "unlock_type": "free",
  "categories": [
    "Sports",
    "Business",
    "Politics"
  ],
  "category_ids": [
    1,
    2,
    3
  ],
  "publication_id": null,
  "issue_id": null,
  "position": null,
  "visible": true,
  "rss_feed_id": null,
  "source": null
}
```

{% endtab %}
{% endtabs %}

## Update an Article

<mark style="color:orange;">`PUT`</mark> `https://www.magloft.com/api/portal/v1/articles/:app_id/:id`

This endpoint **updates** a specific `article` by `id` and **returns** the updated `article`

#### Path Parameters

| Name    | Type    | Description                                     |
| ------- | ------- | ----------------------------------------------- |
| app\_id | String  | App ID (Publication) to scope this request for. |
| id      | Integer | Article ID                                      |

#### Request Body

| Name          | Type                       | Description                                          |
| ------------- | -------------------------- | ---------------------------------------------------- |
| title         | String                     | Article Title                                        |
| info          | String                     | Article Description                                  |
| html          | String                     | Article HTML                                         |
| assets        | Hash                       | Article Assets                                       |
| date          | String                     | Article publish date                                 |
| cover         | String                     | Article Cover                                        |
| category\_ids | Array                      | Article category IDs                                 |
| issue\_id     | Integer                    | Issue ID                                             |
| unlock\_type  | String                     | Unlock Type                                          |
| position      | Integer                    | Order Position of the Article within an Issue        |
| visible       | Virtus::Attribute::Boolean | A boolean indicating whether this article is visible |

{% tabs %}
{% tab title="200 " %}

```javascript
{
  "id": 1234,
  "title": "Welcome to MagLoft",
  "info": null,
  "html": null,
  "assets": null,
  "cover": null,
  "date": null,
  "unlock_type": "free",
  "categories": [
    "Sports",
    "Business",
    "Politics"
  ],
  "category_ids": [
    1,
    2,
    3
  ],
  "publication_id": null,
  "issue_id": null,
  "position": null,
  "visible": true,
  "rss_feed_id": null,
  "source": null
}
```

{% endtab %}
{% endtabs %}

## Delete Article

<mark style="color:red;">`DELETE`</mark> `https://www.magloft.com/api/portal/v1/articles/:app_id/:id`

This endpoint **deletes** a specific `article` by `id` and **returns** an `empty response` with status `204`

#### Path Parameters

| Name    | Type    | Description                                     |
| ------- | ------- | ----------------------------------------------- |
| app\_id | String  | App ID (Publication) to scope this request for. |
| id      | Integer | Article ID                                      |

{% tabs %}
{% tab title="200 " %}

```javascript
null
```

{% endtab %}
{% endtabs %}

## FlexPDF Import

<mark style="color:green;">`POST`</mark> `https://www.magloft.com/api/portal/v1/articles/:app_id/flexpdf-import`

This endpoint **creates** multiple `article` and **returns**

#### Path Parameters

| Name    | Type   | Description                                     |
| ------- | ------ | ----------------------------------------------- |
| app\_id | String | App ID (Publication) to scope this request for. |

#### Request Body

| Name                    | Type    | Description                                   |
| ----------------------- | ------- | --------------------------------------------- |
| articles                | Array   |                                               |
| articles\[title]        | String  | Article Title                                 |
| articles\[html]         | String  | Article HTML                                  |
| articles\[cover]        | String  | Article Cover                                 |
| articles\[issue\_id]    | Integer | Issue ID                                      |
| articles\[unlock\_type] | String  | Unlock Type                                   |
| articles\[position]     | Integer | Order Position of the Article within an Issue |
| articles\[source]       | String  | Article type                                  |

{% tabs %}
{% tab title="200 " %}

```javascript
null
```

{% endtab %}
{% endtabs %}
