### Fetch Latest News with Python (requests) Source: https://currentsapi.services/en/docs A Python example using the `requests` library to get the latest news. Remember to substitute 'YOUR_API_KEY' with your key. ```python import requests headers = { 'Authorization': 'YOUR_API_KEY' } response = requests.get( 'https://api.currentsapi.services/v1/latest-news', headers=headers ) data = response.json() print(data) ``` -------------------------------- ### Fetch Latest News with R (httr) Source: https://currentsapi.services/en/docs An example using R's `httr` package to retrieve the latest news with specified parameters. Substitute 'YOUR_API_KEY' with your actual key. ```r library(httr) res <- GET( "https://api.currentsapi.services/v1/latest-news", query = list(language = "en", page_size = 3, apiKey = "YOUR_API_KEY") ) content(res, "parsed") ``` -------------------------------- ### Fetch Latest News with JavaScript (fetch with parameters) Source: https://currentsapi.services/en/docs Fetch the latest news using JavaScript, including language and page size parameters. Replace 'YOUR_API_KEY' with your key. ```javascript fetch("https://api.currentsapi.services/v1/latest-news?language=en&page_size=3&apiKey=YOUR_API_KEY") .then((res) => res.json()) .then((data) => console.log(data)); ``` -------------------------------- ### Fetch Latest News with JavaScript (fetch) Source: https://currentsapi.services/en/docs This JavaScript snippet demonstrates how to fetch the latest news using the `fetch` API. Ensure you replace 'YOUR_API_KEY' with your valid API key. ```javascript fetch('https://api.currentsapi.services/v1/latest-news', { headers: { 'Authorization': 'YOUR_API_KEY' } }) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Fetch Latest News with cURL (with parameters) Source: https://currentsapi.services/en/docs This cURL command fetches the latest news with specified language and page size. Replace 'YOUR_API_KEY' with your actual API key. ```bash curl "https://api.currentsapi.services/v1/latest-news?language=en&page_size=3&apiKey=YOUR_API_KEY" ``` -------------------------------- ### Fetch Latest News with cURL Source: https://currentsapi.services/en/docs Use this cURL command to fetch the latest news from the API. Replace 'YOUR_API_KEY' with your actual API key. ```bash curl -H "Authorization: YOUR_API_KEY" \ https://api.currentsapi.services/v1/latest-news ``` -------------------------------- ### Fetch Latest News with Python (requests with parameters) Source: https://currentsapi.services/en/docs This Python snippet fetches the latest news with specific parameters using the `requests` library. Ensure 'YOUR_API_KEY' is replaced. ```python import requests response = requests.get( "https://api.currentsapi.services/v1/latest-news", params={"language": "en", "page_size": 3, "apiKey": "YOUR_API_KEY"}, ) print(response.json()) ``` -------------------------------- ### API Response Structure Source: https://currentsapi.services/en/docs This JSON structure illustrates the format of a successful response from the Currents API, detailing the 'news' array and its elements. ```json { "status": "ok", "news": [ { "id": "uuid", "title": "string", "description": "string", "url": "string", "author": "string|null", "image": "string|null", "language": "string", "category": ["string", "..."], "published": "timestamp string" } ], "page": 1 } ``` -------------------------------- ### Latest News Endpoint Source: https://currentsapi.services/en/docs Fetches the latest news articles. Requires an API key for authentication. Supports query parameters for filtering and customization. ```APIDOC ## GET /v1/latest-news ### Description Retrieves the most recent news articles available through the Currents API. ### Method GET ### Endpoint `https://api.currentsapi.services/v1/latest-news` ### Parameters #### Query Parameters - **language** (string) - Optional - Specifies the language of the news articles (e.g., 'en'). - **page_size** (integer) - Optional - Sets the number of articles to return per page. - **apiKey** (string) - Required - Your unique API key for authentication. ### Request Example ```json { "example": "curl \"https://api.currentsapi.services/v1/latest-news?language=en&page_size=3&apiKey=YOUR_API_KEY\"" } ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the response ('ok' for success). - **news** (array) - An array of news article objects. - **id** (string) - Unique identifier for the article. - **title** (string) - The title of the news article. - **description** (string) - A brief description or summary of the article. - **url** (string) - The URL to the full article. - **author** (string|null) - The author of the article, if available. - **image** (string|null) - The URL of the article's main image, if available. - **language** (string) - The language of the article. - **category** (array) - An array of categories the article belongs to. - **published** (timestamp string) - The publication timestamp of the article. - **page** (integer) - The current page number of the results. #### Response Example ```json { "status": "ok", "news": [ { "id": "uuid", "title": "string", "description": "string", "url": "string", "author": "string|null", "image": "string|null", "language": "string", "category": ["string", "..."], "published": "timestamp string" } ], "page": 1 } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.