A comprehensive .NET library for the LanSweeper Data API (GraphQL), providing easy access to LanSweeper's inventory and asset management data.
- Full GraphQL Support: Complete access to LanSweeper's GraphQL Data API
- Type-Safe: Strongly typed C# models for all API responses
- Modern .NET: Built for .NET 9 with modern C# patterns
- Authentication: Seamless Personal Access Token (PAT) authentication
- Error Handling: Comprehensive error handling and custom exceptions
- Async/Await: Full async support for non-blocking operations
- Pagination: Built-in support for GraphQL cursor-based pagination
- Logging: Integrated logging support via Microsoft.Extensions.Logging
- Modular Design: Organized API structure supporting multiple LanSweeper APIs
Install the package via NuGet:
dotnet add package LanSweeper.Apiusing LanSweeper.Api;
// Create client with Personal Access Token
var options = new LanSweeperClientOptions
{
AccessToken = "your-personal-access-token"
};
var client = new LanSweeperClient(options);
// Get authorized sites
var sites = await client.Data.Sites.GetAllAsync();
// Get assets from a site
var assets = await client.Data.Assets.GetBySiteAsync("site-id");
// Execute custom GraphQL query
var result = await client.Data.Reports.ExecuteQueryAsync<CustomModel>("{ your custom query }");LanSweeper.Api uses Personal Access Tokens (PATs) for authentication. To get started:
- Log into your LanSweeper portal
- Navigate to API Access settings
- Generate a Personal Access Token
- Use the token in your
LanSweeperClientOptions
var options = new LanSweeperClientOptions
{
AccessToken = "your-personal-access-token",
GraphQLEndpoint = "https://api.lansweeper.com/api/v2/graphql" // Optional: defaults to this
};The client is organized into logical API groups:
Access to LanSweeper's GraphQL Data API for inventory and asset management:
// Sites API
var sites = await client.Data.Sites.GetAllAsync();
var site = await client.Data.Sites.GetByIdAsync("site-id");
// Assets API
var assets = await client.Data.Assets.GetBySiteAsync("site-id");
var asset = await client.Data.Assets.GetByIdAsync("asset-key");
// Users API
var currentUser = await client.Data.Users.GetCurrentAsync();
// Reports API (Custom Queries)
var result = await client.Data.Reports.ExecuteQueryAsync<T>(query, variables);- Sites: Manage and query LanSweeper scanning sites
- Assets: Access IT inventory and asset data
- Reports: Execute custom reports and queries
- Users: User and permissions management
Note: Support for additional LanSweeper APIs (Device Recognition API, Platform API) coming in future releases.
- .NET 9.0 or later
- Valid LanSweeper account with API access
- Personal Access Token
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.
Note: This is an unofficial library. LanSweeper is a trademark of Lansweeper NV.