Table of Contents

Class AnalyticsApi

Namespace
Cloudflare.NET.Analytics
Assembly
Cloudflare.NET.Analytics.dll

Implements a generic client for the Cloudflare Analytics GraphQL endpoint.

public class AnalyticsApi : IAnalyticsApi
Inheritance
AnalyticsApi
Implements
Inherited Members

Remarks

Initializes a new instance of the AnalyticsApi class.

Constructors

AnalyticsApi(IGraphQLClient, ILoggerFactory)

Implements a generic client for the Cloudflare Analytics GraphQL endpoint.

public AnalyticsApi(IGraphQLClient graphQlClient, ILoggerFactory loggerFactory)

Parameters

graphQlClient IGraphQLClient

The GraphQL client for making requests.

loggerFactory ILoggerFactory

Factory used to create a type-scoped logger.

Remarks

Initializes a new instance of the AnalyticsApi class.

Methods

SendQueryAsync<TResponse>(GraphQLRequest, CancellationToken)

Sends a GraphQL query to the Cloudflare API.

public Task<TResponse> SendQueryAsync<TResponse>(GraphQLRequest request, CancellationToken cancellationToken = default)

Parameters

request GraphQLRequest

The GraphQL request object, containing the query and variables.

cancellationToken CancellationToken

A cancellation token.

Returns

Task<TResponse>

A task that represents the asynchronous operation. The task result contains the deserialized data from the API response's "data" field.

Type Parameters

TResponse

The type to deserialize the GraphQL response data into.

Exceptions

InvalidOperationException

Thrown if the GraphQL API returns errors or if the response data is null.