# News

# Get News Articles List

Retrieve a list of all news articles.

  • URL: blogs/news/
  • Method: GET
  • Response Example:
    [
      {
        "unique_id": "789",
        "headline": "First News",
        "content": "This is the content of the first news article.",
        "category_id": "123",
        "category": {
          "unique_id": "123",
          "name": "Tech",
          "description": "Technology related blogs and news",
          "date_created": "2021-01-01T00:00:00Z",
          "last_updated": "2021-01-01T00:00:00Z"
        },
        "date_created": "2021-01-01T00:00:00Z",
        "last_updated": "2021-01-01T00:00:00Z"
      },
      ...
    ]
    

# Create a News Article

Create a new news article.

  • URL: blogs/news/

  • Method: POST

  • Request Example:

    {
      "headline": "First News",
      "content": "This is the content of the first news article.",
      "category_id": "123"
    }
    

    Create a news article option 2 - you can also send the category as a nested object for defining a new category

    {
      "headline": "First News",
      "content": "This is the content of the first news article.",
      "category": {
        "name": "Tech",
        "description": "Technology related blogs and news"
      }
    }
    
  • Response Example:

    {
      "unique_id": "789",
      "headline": "First News",
      "content": "This is the content of the first news article.",
      "category_id": "123",
      "category": {
        "unique_id": "123",
        "name": "Tech",
        "description": "Technology related blogs and news",
        "date_created": "2021-01-01T00:00:00Z",
        "last_updated": "2021-01-01T00:00:00Z"
      },
      "date_created": "2021-01-01T00:00:00Z",
      "last_updated": "2021-01-01T00:00:00Z"
    }
    

# Get a News Article

Retrieve details of a specific news article by unique ID.

  • URL: blogs/news/<str:unique_id>/
  • Method: GET
  • Response Example:
    {
      "unique_id": "789",
      "headline": "First News",
      "content": "This is the content of the first news article.",
      "category_id": "123",
      "category": {
        "unique_id": "123",
        "name": "Tech",
        "description": "Technology related blogs and news",
        "date_created": "2021-01-01T00:00:00Z",
        "last_updated": "2021-01-01T00:00:00Z"
      },
      "date_created": "2021-01-01T00:00:00Z",
      "last_updated": "2021-01-01T00:00:00Z"
    }
    

# Update a News Article

Update an existing news article by unique ID.

  • URL: blogs/news/<str:unique_id>/
  • Method: PUT
  • Request Example:
    {
      "headline": "Updated News",
      "content": "This is the updated content of the news article.",
      "category_id": "123"
    }
    
  • Response Example:
    {
      "unique_id": "789",
      "headline": "Updated News",
      "content": "This is the updated content of the news article.",
      "category_id": "123",
      "category": {
        "unique_id": "123",
        "name": "Tech",
        "description": "Technology related blogs and news",
        "date_created": "2021-01-01T00:00:00Z",
        "last_updated": "2021-01-01T00:00:00Z"
      },
      "date_created": "2021-01-01T00:00:00Z",
      "last_updated": "2021-01-02T00:00:00Z"
    }
    

# Delete a News Article

Delete a news article by unique ID.

  • URL: blogs/news/<str:unique_id>/
  • Method: DELETE
  • Response: 204 No Content