Skip to main content

Client

Struct Client 

Source
pub struct Client { /* private fields */ }

Implementations§

Source§

impl Client

Source

pub fn new(config: Config) -> Result<Self, ClientError>

Creates a new Client instance using the provided Config.

§Arguments
  • config - A validated Config instance.
§Errors

Returns an error if the HTTP client fails to initialize.

Source

pub async fn get_feeds(&self) -> Result<Vec<Feed>, ClientError>

Returns a list of available feeds.

§Endpoint:
/api/v1/feeds
§Type:
  • HTTP GET
§Sample request:
GET /api/v1/feeds
§Error Response Codes
Status CodeDescription
400 Bad RequestThis error is triggered when:
- There is any missing/malformed query argument.
- Required headers are missing or provided with incorrect values.
401 Unauthorized UserThis error is triggered when:
- Authentication fails, typically because the HMAC signature provided by the client doesn’t match the one expected by the server.
- A user requests access to a feed without the appropriate permission or that does not exist.
500 Internal ServerIndicates an unexpected condition encountered by the server, preventing it from fulfilling the request. This error typically points to issues on the server side.
Source

pub async fn get_latest_report( &self, feed_id: ID, ) -> Result<ReportResponse, ClientError>

Returns a single report with the latest timestamp.

§Endpoint:
/api/v1/reports/latest
§Type:
  • HTTP GET
§Parameters:
  • feedID - A Data Streams feed ID.
§Sample request:
GET /api/v1/reports/latest?feedID={feedID}
§Sample response:
{
    "report": {
        "feedID": "Hex encoded feedId.",
        "validFromTimestamp": "Report's earliest applicable timestamp (in seconds).",
        "observationsTimestamp": "Report's latest applicable timestamp (in seconds).",
        "fullReport": "A blob containing the report context and body. Encode the fee token into the payload before passing it to the contract for verification."
   }
}
§Error Response Codes
Status CodeDescription
400 Bad RequestThis error is triggered when:
- There is any missing/malformed query argument.
- Required headers are missing or provided with incorrect values.
401 Unauthorized UserThis error is triggered when:
- Authentication fails, typically because the HMAC signature provided by the client doesn’t match the one expected by the server.
- A user requests access to a feed without the appropriate permission or that does not exist.
500 Internal ServerIndicates an unexpected condition encountered by the server, preventing it from fulfilling the request. This error typically points to issues on the server side.
Source

pub async fn get_report( &self, feed_id: ID, timestamp: u128, ) -> Result<ReportResponse, ClientError>

Returns a single report at a given timestamp.

§Endpoint:
/api/v1/reports
§Type:
  • HTTP GET
§Parameters:
  • feedID - A Data Streams feed ID.
  • timestamp - The Unix timestamp for the report (in seconds).
§Sample request:
GET /api/v1/reports?feedID={feedID}&timestamp={timestamp}
§Sample response:
{
    "report": {
        "feedID": "Hex encoded feedId.",
        "validFromTimestamp": "Report's earliest applicable timestamp (in seconds).",
        "observationsTimestamp": "Report's latest applicable timestamp (in seconds).",
        "fullReport": "A blob containing the report context and body. Encode the fee token into the payload before passing it to the contract for verification."
    }
}
§Error Response Codes
Status CodeDescription
400 Bad RequestThis error is triggered when:
- There is any missing/malformed query argument.
- Required headers are missing or provided with incorrect values.
401 Unauthorized UserThis error is triggered when:
- Authentication fails, typically because the HMAC signature provided by the client doesn’t match the one expected by the server.
- A user requests access to a feed without the appropriate permission or that does not exist.
500 Internal ServerIndicates an unexpected condition encountered by the server, preventing it from fulfilling the request. This error typically points to issues on the server side.
Source

pub async fn get_reports_bulk( &self, feed_ids: &[ID], timestamp: u128, ) -> Result<Vec<Report>, ClientError>

Returns a report for multiple FeedIDs at a given timestamp.

§Endpoint:
/api/v1/reports/bulk
§Type:
  • HTTP GET
§Parameters:
  • feedIDs - A comma-separated list of Data Streams feed IDs.
  • timestamp - The Unix timestamp for the reports (in seconds).
§Sample request:
GET /api/v1/reports/bulk?feedIDs={FeedID1},{FeedID2},...&timestamp={timestamp}
§Sample response:
{
    "reports": [
        {
            "feedID": "Hex encoded feedId.",
            "validFromTimestamp": "Report's earliest applicable timestamp (in seconds).",
            "observationsTimestamp": "Report's latest applicable timestamp (in seconds).",
            "fullReport": "A blob containing the report context and body. Encode the fee token into the payload before passing it to the contract for verification."
        },
        //...
    ]
}
§Error Response Codes
Status CodeDescription
400 Bad RequestThis error is triggered when:
- There is any missing/malformed query argument.
- Required headers are missing or provided with incorrect values.
401 Unauthorized UserThis error is triggered when:
- Authentication fails, typically because the HMAC signature provided by the client doesn’t match the one expected by the server.
- A user requests access to a feed without the appropriate permission or that does not exist.
500 Internal ServerIndicates an unexpected condition encountered by the server, preventing it from fulfilling the request. This error typically points to issues on the server side.
206 Missing DataIndicates that at least one feed ID data is missing from the report. E.g., you requested a report for feed IDs <feedID1>, <feedID2>, and <feedID3> at a given timestamp. If data for <feedID2> is missing from the report (not available yet at the specified timestamp), you get [<feedID1 data>, <feedID3 data>] and a 206 response.
Source

pub async fn get_reports_page( &self, feed_id: ID, start_timestamp: u128, ) -> Result<Vec<Report>, ClientError>

Returns multiple sequential reports for a single FeedID, starting at a given timestamp

§Endpoint:
/api/v1/reports
§Type:
  • HTTP GET
§Parameters:
  • feedID - A Data Streams feed ID.
  • startTimestamp - The UNIX timestamp for the first report (in seconds).
§Sample request:
GET /api/v1/reports/page?feedID={FeedID}&startTimestamp={StartTimestamp}
§Sample response:
{
    "reports": [
        {
            "feedID": "Hex encoded feedId.",
            "validFromTimestamp": "Report's earliest applicable timestamp (in seconds).",
            "observationsTimestamp": "Report's latest applicable timestamp (in seconds).",
            "fullReport": "A blob containing the report context and body. Encode the fee token into the payload before passing it to the contract for verification."
        },
        //...
    ]
}
§Error Response Codes
Status CodeDescription
400 Bad RequestThis error is triggered when:
- There is any missing/malformed query argument.
- Required headers are missing or provided with incorrect values.
401 Unauthorized UserThis error is triggered when:
- Authentication fails, typically because the HMAC signature provided by the client doesn’t match the one expected by the server.
- A user requests access to a feed without the appropriate permission or that does not exist.
500 Internal ServerIndicates an unexpected condition encountered by the server, preventing it from fulfilling the request. This error typically points to issues on the server side.
Source

pub async fn get_reports_page_with_limit( &self, feed_id: ID, start_timestamp: u128, limit: usize, ) -> Result<Vec<Report>, ClientError>

Returns multiple sequential reports for a single FeedID, starting at a given timestamp

§Endpoint:
/api/v1/reports
§Type:
  • HTTP GET
§Parameters:
  • feedID - A Data Streams feed ID.
  • startTimestamp - The UNIX timestamp for the first report (in seconds).
  • limit - The number of reports to return
§Sample request:
GET /api/v1/reports/page?feedID={FeedID}&startTimestamp={StartTimestamp}&limit={Limit}
§Sample response:
{
    "reports": [
        {
            "feedID": "Hex encoded feedId.",
            "validFromTimestamp": "Report's earliest applicable timestamp (in seconds).",
            "observationsTimestamp": "Report's latest applicable timestamp (in seconds).",
            "fullReport": "A blob containing the report context and body. Encode the fee token into the payload before passing it to the contract for verification."
        },
        //...
    ]
}
§Error Response Codes
Status CodeDescription
400 Bad RequestThis error is triggered when:
- There is any missing/malformed query argument.
- Required headers are missing or provided with incorrect values.
401 Unauthorized UserThis error is triggered when:
- Authentication fails, typically because the HMAC signature provided by the client doesn’t match the one expected by the server.
- A user requests access to a feed without the appropriate permission or that does not exist.
500 Internal ServerIndicates an unexpected condition encountered by the server, preventing it from fulfilling the request. This error typically points to issues on the server side.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,