pub struct NewsDataClient { /* private fields */ }Expand description
Client for NewsData.io API
Implementations§
Source§impl NewsDataClient
impl NewsDataClient
Sourcepub fn new(api_key: Option<String>) -> Result<Self>
pub fn new(api_key: Option<String>) -> Result<Self>
Create a new NewsData client
§Arguments
api_key- NewsData.io API key (get from https://newsdata.io/)
Free tier: 200 requests/day
Sourcepub async fn get_latest(
&self,
query: Option<&str>,
country: Option<&str>,
category: Option<&str>,
) -> Result<Vec<DataRecord>>
pub async fn get_latest( &self, query: Option<&str>, country: Option<&str>, category: Option<&str>, ) -> Result<Vec<DataRecord>>
Get latest news
§Arguments
query- Search query (optional)country- Country code (optional, e.g., “us”, “gb”)category- Category (optional, e.g., “technology”, “business”)
Sourcepub async fn get_archive(
&self,
query: Option<&str>,
from_date: &str,
to_date: &str,
) -> Result<Vec<DataRecord>>
pub async fn get_archive( &self, query: Option<&str>, from_date: &str, to_date: &str, ) -> Result<Vec<DataRecord>>
Get archived/historical news
§Arguments
query- Search query (optional)from_date- Start date (YYYY-MM-DD)to_date- End date (YYYY-MM-DD)
Trait Implementations§
Source§impl DataSource for NewsDataClient
impl DataSource for NewsDataClient
Source§fn fetch_batch<'life0, 'async_trait>(
&'life0 self,
_cursor: Option<String>,
_batch_size: usize,
) -> Pin<Box<dyn Future<Output = Result<(Vec<DataRecord>, Option<String>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn fetch_batch<'life0, 'async_trait>(
&'life0 self,
_cursor: Option<String>,
_batch_size: usize,
) -> Pin<Box<dyn Future<Output = Result<(Vec<DataRecord>, Option<String>)>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Fetch a batch of records starting from cursor
Auto Trait Implementations§
impl Freeze for NewsDataClient
impl !RefUnwindSafe for NewsDataClient
impl Send for NewsDataClient
impl Sync for NewsDataClient
impl Unpin for NewsDataClient
impl !UnwindSafe for NewsDataClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more