Table of Contents

Class MerakiClient

Namespace
Meraki.Api
Assembly
Meraki.Api.dll

A Meraki Dashboard API client. This is your starting point for all API operations. Example usage:

using Meraki.Api;
using System;
using System.Threading.Tasks;

namespace My.Project;
public static class Program
{
    public static async Task Main()
    {
        using var merakiClient = new MerakiClient(
            new MerakiClientOptions
            {
                ApiKey = "0123456789abcdef0123456789abcdef01234567",
                UserAgent = "YourProductName/YourProductVersion YourCompanyName"
            }
        );

        var organizations = await merakiClient
            .Organizations
            .GetOrganizationsAsync()
            .ConfigureAwait(false);

        var firstOrganization = organizations[0];

        var devices = await merakiClient
            .Organizations
            .Devices
            .GetOrganizationDevicesAsync(firstOrganization.Id)
            .ConfigureAwait(false);

        Console.WriteLine("Devices:");
        foreach (var device in devices)
        {
            Console.WriteLine($"    - {device.Serial}: {device.Name}");
        }
    }
}
public class MerakiClient : IDisposable
Inheritance
MerakiClient
Implements
Inherited Members

Remarks

This routes through the same core HttpClient as every typed endpoint, so it inherits authentication, read-only gating, rate limiting and 429/5xx back-off from the internal authenticated handler automatically. It exists so callers that need endpoints not (yet) surfaced as typed methods - or that must choose the endpoint at runtime - can still benefit from the client's transport behaviour.

Constructors

MerakiClient(MerakiClientOptions, ILogger?)

A Meraki portal client

public MerakiClient(MerakiClientOptions options, ILogger? logger = null)

Parameters

options MerakiClientOptions
logger ILogger

Properties

ApiClientVersion

Gets the api client version

public string ApiClientVersion { get; }

Property Value

string

Appliance

Gets the appliance

public ApplianceSection Appliance { get; }

Property Value

ApplianceSection

Camera

Generate a snapshot of what the camera sees at the specified time and return a link to that image.

public CameraSection Camera { get; }

Property Value

CameraSection

CellularGateway

Gets the cellular gateway

public CellularGatewaySection CellularGateway { get; }

Property Value

CellularGatewaySection

Devices

Return a single device

public DevicesSection Devices { get; }

Property Value

DevicesSection

Insight

Gets the insight

public InsightSection Insight { get; }

Property Value

InsightSection

IsReadOnly

Used to find out whether the client has the ReadOnly option set

public bool IsReadOnly { get; }

Property Value

bool

LastRequestUri

Gets the URI of the last API request made by this client

public string LastRequestUri { get; }

Property Value

string

LastResponseHeaders

Gets the last response headers

public HttpResponseHeaders? LastResponseHeaders { get; set; }

Property Value

HttpResponseHeaders

Licensing

Gets the licensing

public LicensingSection Licensing { get; }

Property Value

LicensingSection

LiveTools

Gets the live tools

public LiveToolsSection LiveTools { get; }

Property Value

LiveToolsSection

Networks

Return a network

public NetworksSection Networks { get; }

Property Value

NetworksSection

Organizations

List the organizations that the user has privileges on

public OrganizationsSection Organizations { get; }

Property Value

OrganizationsSection

SecureConnect

Gets the secure connect

public SecureConnectSection SecureConnect { get; }

Property Value

SecureConnectSection

Sensor

Gets the sensor

public SensorSection Sensor { get; }

Property Value

SensorSection

SensorRanges

Gets sensor reading ranges and thresholds for various sensor metrics, consistent with the Meraki Dashboard UI

public static Dictionary<SensorMetrics, List<SensorRange>> SensorRanges { get; }

Property Value

Dictionary<SensorMetrics, List<SensorRange>>

Sm

Gets the sm

public SmSection Sm { get; }

Property Value

SmSection

Statistics

Gets statistics about API requests made by this client

public MerakiClientStatistics Statistics { get; }

Property Value

MerakiClientStatistics

Switch

Gets the switch

public SwitchSection Switch { get; }

Property Value

SwitchSection

Wireless

Gets the wireless

public WirelessSection Wireless { get; }

Property Value

WirelessSection

Methods

Dispose()

Dispose

public void Dispose()

Dispose(bool)

Releases the unmanaged resources used by the MerakiClient and optionally releases the managed resources

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

true to release both managed and unmanaged resources; false to release only unmanaged resources

GetAllAsync<T>(Func<int, string?, string?, CancellationToken, Task<List<T>>>, int, CancellationToken)

Retrieves all items using pagination with a per-page count parameter

public Task<List<T>> GetAllAsync<T>(Func<int, string?, string?, CancellationToken, Task<List<T>>> pageFactoryAsync, int perPage, CancellationToken cancellationToken)

Parameters

pageFactoryAsync Func<int, string, string, CancellationToken, Task<List<T>>>

The function to call for each page of results

perPage int

The number of items per page

cancellationToken CancellationToken

The cancellation token

Returns

Task<List<T>>

A list of all items

Type Parameters

T

The type of items to retrieve

GetAllAsync<T>(Func<int?, string?, string?, CancellationToken, Task<ApiResponse<List<T>>>>, int, CancellationToken)

Retrieves all items using pagination with per-page count and ApiResponse wrapper

public static Task<List<T>> GetAllAsync<T>(Func<int?, string?, string?, CancellationToken, Task<ApiResponse<List<T>>>> pageFactoryAsync, int perPage, CancellationToken cancellationToken)

Parameters

pageFactoryAsync Func<int?, string, string, CancellationToken, Task<ApiResponse<List<T>>>>

The function to call for each page of results

perPage int

The number of items per page

cancellationToken CancellationToken

The cancellation token

Returns

Task<List<T>>

A list of all items

Type Parameters

T

The type of items to retrieve

GetAllAsync<T>(Func<string?, string?, string?, string?, double?, CancellationToken, Task<ApiResponse<List<T>>>>, string?, string?, double?, CancellationToken)

Retrieves all items using pagination with time-based parameters

public static Task<List<T>> GetAllAsync<T>(Func<string?, string?, string?, string?, double?, CancellationToken, Task<ApiResponse<List<T>>>> pageFactoryAsync, string? t0 = null, string? t1 = null, double? timeSpan = null, CancellationToken cancellationToken = default)

Parameters

pageFactoryAsync Func<string, string, string, string, double?, CancellationToken, Task<ApiResponse<List<T>>>>

The function to call for each page of results

t0 string

The beginning of the timespan

t1 string

The end of the timespan

timeSpan double?

The timespan duration

cancellationToken CancellationToken

The cancellation token

Returns

Task<List<T>>

A list of all items

Type Parameters

T

The type of items to retrieve

GetAllAsync<T>(Func<string?, string?, CancellationToken, Task<ApiResponse<List<T>>>>, CancellationToken)

Retrieves all items using pagination with ApiResponse wrapper

public static Task<List<T>> GetAllAsync<T>(Func<string?, string?, CancellationToken, Task<ApiResponse<List<T>>>> pageFactoryAsync, CancellationToken cancellationToken)

Parameters

pageFactoryAsync Func<string, string, CancellationToken, Task<ApiResponse<List<T>>>>

The function to call for each page of results

cancellationToken CancellationToken

The cancellation token

Returns

Task<List<T>>

A list of all items

Type Parameters

T

The type of items to retrieve

GetAllAsync<T>(Func<string?, string?, CancellationToken, Task<List<T>>>, CancellationToken)

Retrieves all items using pagination with startingAfter/endingBefore parameters

public Task<List<T>> GetAllAsync<T>(Func<string?, string?, CancellationToken, Task<List<T>>> pageFactoryAsync, CancellationToken cancellationToken)

Parameters

pageFactoryAsync Func<string, string, CancellationToken, Task<List<T>>>

The function to call for each page of results

cancellationToken CancellationToken

The cancellation token

Returns

Task<List<T>>

A list of all items

Type Parameters

T

The type of items to retrieve

GetAllFromResponsePropertyAsync<TResponse, TModel>(Func<string?, string?, CancellationToken, Task<ApiResponse<TResponse>>>, Func<ApiResponse<TResponse>, List<TModel>>, CancellationToken)

Retrieves all items from a paginated API response where the data is accessed via a custom accessor function.

public static Task<List<TModel>> GetAllFromResponsePropertyAsync<TResponse, TModel>(Func<string?, string?, CancellationToken, Task<ApiResponse<TResponse>>> pageFactoryAsync, Func<ApiResponse<TResponse>, List<TModel>> propertyFunction, CancellationToken cancellationToken)

Parameters

pageFactoryAsync Func<string, string, CancellationToken, Task<ApiResponse<TResponse>>>

A function that asynchronously retrieves a page of data, given pagination parameters and a cancellation token.

propertyFunction Func<ApiResponse<TResponse>, List<TModel>>

A function that extracts a list of models from the API response.

cancellationToken CancellationToken

A cancellation token to observe while waiting for the task to complete.

Returns

Task<List<TModel>>

A task that represents the asynchronous operation. The task result contains a list of all models retrieved from all pages.

Type Parameters

TResponse

The type of the API response object.

TModel

The type of the model to return in the list.

GetEndOfLifeDetailsAsync(CancellationToken)

public static Task<List<DeviceModelEndOfLifeDetail>> GetEndOfLifeDetailsAsync(CancellationToken cancellationToken = default)

Parameters

cancellationToken CancellationToken

Returns

Task<List<DeviceModelEndOfLifeDetail>>

Exceptions

ApiException

Thrown when fails to make API call

GetInfoFromSerialNumber(string)

public static SerialNumberInfo GetInfoFromSerialNumber(string serialNumber)

Parameters

serialNumber string

Returns

SerialNumberInfo

QueryAsync(HttpMethod, string, string?, string?, bool, CancellationToken)

Executes an arbitrary Meraki Dashboard API v1 request.

public Task<MerakiQueryResponse> QueryAsync(HttpMethod method, string path, string? body = null, string? contentType = "application/json", bool followPagination = true, CancellationToken cancellationToken = default)

Parameters

method HttpMethod

The HTTP method. Non-GET methods throw if the client is read-only.

path string

The path AFTER /api/v1/ (e.g. organizations or organizations/{orgId}/appliance/uplink/statuses), optionally including a query string. A leading slash is ignored.

body string

The raw request body to send, or null for none.

contentType string

The Content-Type for the body. Defaults to application/json.

followPagination bool

When true (default), GET requests that return a JSON array and a Link: rel=next header are followed to completion and all pages are concatenated. Ignored for non-GET requests and non-array responses.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<MerakiQueryResponse>

A MerakiQueryResponse describing the (final) response and its parsed JSON.

SetReadOnly(bool)

Used to change the Options Readonly state after client is created

public void SetReadOnly(bool readOnly)

Parameters

readOnly bool