A Dart package that allows interaction with the
NuGet Server API. This package provides easy access to
the NuGet Server API
, allowing you to perform various operations such as
querying package information, downloading package content, fetching package
metadata, and more.
- Autocomplete package IDs
- Download package content (
.nupkg
) - Download package manifest (
.nuspec
) - Get all package metadata (all versions)
- Get latest package version
- Get package metadata (specific version)
- Get package versions
- Check if a package exists
- Get report abuse URL for a package
- Search packages
import 'package:nuget/nuget.dart';
void main() async {
// Create an instance of NuGetClient.
final client = NuGetClient();
const query = 'win32';
final response = await client.autocompletePackageIds(query);
print('The `$query` query returned ${response.totalHits} hits. '
'Here are the first 20 results:');
for (final packageId in response.data) {
print(' - $packageId');
}
// Close the client when it's no longer needed.
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const packageId = 'Newtonsoft.Json';
const version = '13.0.3';
final content =
await client.downloadPackageContent(packageId, version: version);
print('`$packageId` ($version) package size: ${content.length} bytes');
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const packageId = 'Newtonsoft.Json';
const version = '13.0.3';
final manifest =
await client.downloadPackageManifest(packageId, version: version);
print('`$packageId` ($version) manifest size: ${manifest.length} bytes');
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const packageId = 'Newtonsoft.Json';
final allMetadata = await client.getAllPackageMetadata(packageId);
print('`$packageId` metadata of first three versions:');
for (final metadata in allMetadata.take(3)) {
print(' - Version: ${metadata.version}');
print(' - Description: ${metadata.description}');
print(' - Author(s): ${metadata.authors}');
print('');
}
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const packageId = 'Newtonsoft.Json';
final latestVersion = await client.getLatestPackageVersion(packageId);
print('`$packageId` latest version: $latestVersion');
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const packageId = 'Newtonsoft.Json';
const version = '13.0.3';
final metadata = await client.getPackageMetadata(packageId, version: version);
print('`$packageId` ($version) metadata:');
print(' - Version: ${metadata.version}');
print(' - Description: ${metadata.description}');
print(' - Author(s): ${metadata.authors}');
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const packageId = 'Newtonsoft.Json';
final versions = await client.getPackageVersions(packageId);
print('`$packageId` has ${versions.length} versions:');
for (final version in versions) {
print(' - $version');
}
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const packageId = 'Newtonsoft.Json';
final exists = await client.packageExists(packageId);
print('`$packageId` exists: $exists');
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const packageId = 'Newtonsoft.Json';
const version = '13.0.3';
final reportAbuseUrl = await client.getReportAbuseUrl(packageId, version);
print('Report abuse URL for `$packageId` ($version): $reportAbuseUrl');
client.close();
}
import 'package:nuget/nuget.dart';
void main() async {
final client = NuGetClient();
const query = 'win32';
final searchResponse = await client.searchPackages(query);
print('The `$query` query returned ${searchResponse.totalHits} hits. Here '
'are the first 20 results:');
for (final package in searchResponse.data) {
print(' - ${package.packageId} (${package.version})');
}
client.close();
}
Please file feature requests and bugs at the issue tracker.