- Notifications
You must be signed in to change notification settings - Fork19
The most complete & unofficial API Client for Dart Pub.dev
License
leoafarias/pub_api_client
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
An unofficial API client forPub.dev
Aims to be the most complete and stable pub.dev API client. If any particular endpoint is missing pleaseopen an issue.
A simple usage example:
import'package:pub_api_client/pub_api_client.dart';main() {final client=PubClient();}
Retrieves all available information about an specific package.
final package=await client.packageInfo('pkg_name');
Returns the following score information about a package.
- Pub Points
- Popularity
- Likes
final score=await client.packageScore('pkg_name');
The method 'packageMetrics' returns the package 'score' together with a 'scorecard'
final metrics=await client.packageMetrics('pkg_name');
The method 'packageVersions' also returns the versions. However if all you need is versions use this method since it's lighter.
final versions=await client.packageVersions('pkg_name');
The methodpackageVersionInfo
returns information about a version of a specific package.
final version=await client.packageVersionInfo('pkg_name','version');
The methodpackagePublisher
returns the publisherId of a specific package.
final publisher=await client.packagePublisher('pkg_name');// publisher.publisherId
The methodpackageOptions
returns options of a package.
final options=await client.packageOptions('pkg_name');
The methoddocumentation
returns all versions and their respective documentation status.
final documentation=await client.documentation('pkg_name');
All requests for likes require pub.dev authentication.
Displays list of of packages you have liked. Returns list ofpackageLikes
final likes=await client.listPackageLikes();
Returns like status of a package.
final like=await client.likePackageStatus();
Likes a package. The method returnspackageLike
payload
final like=await client.likePackage('pkg_name');
Unlikes a package. The method returnspackageLike
payload
final like=await client.unlikePackage('pkg_name');
Search for packages on pub.dev. Will return the packages that match the query. You can filter the search with tags.
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)
You are able to sort search results by the following:
Search score should be a weighted value of [text], [popularity], [points] and [like], ordered decreasing.
Search score should depend only on text match similarity, ordered decreasing.
Search order should be in decreasing last package creation time.
Search order should be in decreasing last package updated time.
Search order should be in decreasing popularity score.
Search order should be in decreasing like count.
Search order should be in decreasing pub points.
final results=await client.search('query', sort:SearchOrder.updated);print(results.packages)
You are able to page search results.
final results=await client.search('query');final nextPage= results.next;if (nextPage!=null) {final nextResults=await client.nextPage(nextPage);}print(nextResults.packages)
If you want to retrieve a specific result page you can call thepage
parameter directly.
final results=await client.search('query',page:2);print(results.packages)
Returns all Flutter favorites on pub.dev
final results=await client.fetchFlutterFavorites();
Returns all official Google packages. This will be a large payload with hundreds of packages.
final results=await client.fetchGooglePackages();
Returns all packages for a specific publisher
final results=await client.fetchPublisherPackages();
Returns all packages that match a given query
final results=awaitfetchAllPackages('', tags: [PackageTag.publisher('leoafarias.com')])
About
The most complete & unofficial API Client for Dart Pub.dev