Flutter/Dart 패키지로, Pub 패키지 저장소와 상호작용할 수 있는 클라이언트를 제공하여 개발자가 메타데이터, 버전, 종속성 등의 공개 패키지 정보를 가져올 수 있도록 합니다. 간단함과 신뢰성을 위해 설계되었으며, 실시간으로 Dart 패키지 데이터에 접근이 필요한 앱에 원활하게 통합됩니다. 모바일, 데스크톱, 웹을 포함한 모든 주요 플랫폼을 지원하여 패키지 세부 정보를 분석하거나 표시하는 도구에 이상적입니다. leoafarias.com에서 유지보수되며, 투명성과 커뮤니티 기여를 위해 GitHub에 호스팅되어 있습니다.
import'package:pub_api_client/pub_api_client.dart';
voidmain() {
final client = PubClient();
}
API
Packages
Get Package Info
Retrieves all available information about a specific package.
final package = await client.packageInfo('pkg_name');
Package pubspec dependencies retain their typed source metadata. The public
library exports HostedDependency, GitDependency, PathDependency, and
SdkDependency so consumers can inspect constraints, URLs, refs, subpaths, and
SDK names without importing an implementation dependency separately.
Get Package Score
Returns the following score information about a package.
Pub Points (grantedPoints / maxPoints)
Likes (likeCount)
30-day downloads (downloadCount30Days)
Tags
final score = await client.packageScore('pkg_name');
popularityScore is always null — pub.dev retired the popularity score.
Use downloadCount30Days instead.
Get Package Metrics
The packageMetrics method returns a package score and scorecard.
final metrics = await client.packageMetrics('pkg_name');
final weekly = metrics?.scorecard.weeklyVersionDownloads;
if (weekly != null && weekly.totalWeeklyDownloads.isNotEmpty) {
print('Latest weekly downloads: ${weekly.totalWeeklyDownloads.last}');
}
When supplied by the server, the scorecard includes total weekly downloads and
major, minor, and patch version-range histories.
Get Package Versions
The packageVersions method returns only the published version strings.
final versions = await client.packageVersions('pkg_name');
Get Package Version Info
The packageVersionInfo method returns information about a specific package
version.
final version = await client.packageVersionInfo('pkg_name', 'version');
Get Package Version Score
The method packageVersionScore returns the score of a single version.
final score = await client.packageVersionScore('pkg_name', 'version');
Get Package Version Options
The method packageVersionOptions tells whether a specific version has been
retracted.
final options = await client.packageVersionOptions('pkg_name', 'version');
print(options.isRetracted);
Get Package Publisher
The packagePublisher method returns the publisher ID of a specific package.
final publisher = await client.packagePublisher('pkg_name');
print(publisher.publisherId);
Get Package Likes
The method packageLikes returns the public like count of a package. Unlike
the like endpoints this does not require authentication.
final likes = await client.packageLikes('pkg_name');
print(likes.likes);
Get Package Options
The method packageOptions returns options of a package.
final options = await client.packageOptions('pkg_name');
Get Documentation
The documentation method returns each version and its documentation status.
final documentation = await client.documentation('pkg_name');
Get Security Advisories
The method packageAdvisories returns the security advisories affecting a
package, in OSV format. Returns null
when the server does not implement the endpoint.
final advisories = await client.packageAdvisories('pkg_name');
if (advisories != null && advisories.advisories.isNotEmpty) {
print(advisories.advisories.first.pubDisplayUrl);
}
Publishers
Get Publisher Info
The method publisherInfo returns the public profile of a publisher.
final publisher = await client.publisherInfo('dart.dev');
print(publisher.description);
Like Packages
The endpoints in this section inspect or change the authenticated user's like
state and require pub.dev authentication. The package-wide count returned by
packageLikes is public.
List liked packages
Returns the packages liked by the authenticated user.
final likes = await client.listPackageLikes();
Package Like Status
Returns like status of a package.
final like = await client.likePackageStatus('pkg_name');
Like a Package
Likes a package and returns its authenticated like status.
final like = await client.likePackage('pkg_name');
Unlike a Package
Unlikes a package.
await client.unlikePackage('pkg_name');
Search Packages
Searches pub.dev for packages matching a query, with optional tag and topic
filters.
final results = await client.search(
'query',
tags: [
PackageTag.publisher('publisher_id'),
PackageTag.dependency('dependency_name'),
'another:tag',
],
topics: ['topic_1', 'topic_2'],
);
// Returns the packages that match the queryprint(results.packages);
Sorting search results
Search results support these orderings:
Value
Orders by
SearchOrder.top
Weighted text, downloads, points, and likes
SearchOrder.text
Text-match similarity
SearchOrder.created
Package creation time
SearchOrder.updated
Last update time
SearchOrder.downloads
Download count
SearchOrder.like
Like count
SearchOrder.points
Pub points
SearchOrder.trending
Trend score
final results = await client.search('query', sort: SearchOrder.updated);
print(results.packages);
SearchOrder.popularity is deprecated. pub.dev no longer accepts it and
silently serves those requests as SearchOrder.top. Use
SearchOrder.downloads.
Paging Search Results
Use the next URL to page through search results.
final results = await client.search('query');
final nextPage = results.next;
if (nextPage != null) {
final nextResults = await client.nextPage(nextPage);
print(nextResults.packages);
}
To retrieve a specific result page, pass the page parameter directly.
final results = await client.search('query', page: 2);
print(results.packages);
pub.dev stops returning a next link after page 10, so paging through a
search yields at most 100 packages.
Completion Data
Package Names
packageNameCompletion returns the top package names on pub.dev, and
packageNames returns every package name in one gzip-compressed response.
final top = await client.packageNameCompletion();
final all = await client.packageNames();
Topics
topicNameCompletion returns every topic mapped to the number of packages
using it.
final results = await client.fetchFlutterFavorites();
Google Packages
Returns official Google packages across the known Google publishers.
final results = await client.fetchGooglePackages();
Publisher Packages
Returns all packages for a specific publisher.
final results = await client.fetchPublisherPackages('dart.dev');
All Packages
Returns all packages that match a given query.
final results = await client.fetchAllPackages(
'',
tags: [PackageTag.publisher('leoafarias.com')],
);
pub.dev caps each search at 10 pages. fetchAllPackages,
fetchPublisherPackages, and fetchFlutterFavorites therefore return at
most 100 packages per query. fetchGooglePackages applies the same limit
separately to each known publisher.