Skip to content

Commit

Permalink
Updates
Browse files Browse the repository at this point in the history
  • Loading branch information
leoafarias committed Oct 20, 2020
1 parent 4d5ae90 commit 32dbfe9
Show file tree
Hide file tree
Showing 24 changed files with 2,570 additions and 2 deletions.
33 changes: 33 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Files and directories created by pub
.dart_tool/
.packages
# Remove the following pattern if you wish to check in your lock file
pubspec.lock
# Do not version the sdk versions
.DS_Store

# Conventional directory for build outputs
build/

# Directory created by dartdoc
doc/api/

# Test Coverage
test/.test_coverage.dart

# IntelliJ related
*.iml
*.ipr
*.iws
.idea/

# Visual Studio Code related
.classpath
.project
.settings/
.vscode/
coverage/lcov.info

# FVM during tests
.fvm
.vscode/settings.json
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
## 1.0.3

- Added user-agent to requests

## 1.0.2

- Further improvements

## 1.0.1

- Test improvements and API clean up

## 1.0.0

- Initial version
81 changes: 79 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,79 @@
# pubdev_api
API Client for Pub.dev
<img src="https://github.com/leoafarias/pub_api_client/blob/main/assets/logo.png?raw=true" alt="drawing" width="320"/>

[![Pub Version](https://img.shields.io/pub/v/pub_api_client?label=version&style=flat-square)](https://pub.dev/packages/pub_api_client/changelog) [![Health](https://img.shields.io/badge/dynamic/json?color=blue&label=health&query=pub_points&url=http://www.pubscore.gq/pub-points?package=pub_api_client&style=flat-square&cacheSeconds=90000)](https://pub.dev/packages/pub_api_client/score) [![Coverage Status](https://coveralls.io/repos/github/leoafarias/pub_api_client/badge.svg?branch=main)](https://coveralls.io/github/leoafarias/pub_api_client?branch=main) [![MIT Licence](https://img.shields.io/github/license/leoafarias/pub_api_client?style=flat-square&longCache=true)](https://opensource.org/licenses/mit-license.php)

## An unofficial API client for [Pub.dev](https://www.pub.dev)

Implements all `known` endpoints available on pub.dev. If any particular endpoint is missing please [open an issue][tracker].

## Usage

A simple usage example:

```dart
import 'package:pub_api_client/pub_api_client.dart';
main() {
final client = PubClient();
}
```

## Get Package Info

Retrieves all available information about an specific package.

```dart
final package = await client.getPackage('pkg_name');
```

## Get Package Score

Returns the following score information about a package.

- Pub Points
- Popularity
- Likes

```dart
final score = await client.getScore('pkg_name');
```

## Get Package Versions

The method `getPackage` also returns the versions. However if all you need is versions use this method since it's lighter.

```dart
final package = await client.getVersions('pkg_name');
```

## Search Packages

Allows you to search for packages on pub.dev. Will return the packages that match the query.

```dart
final results = await client.search('query');
// Returns the packages that match the query
print(results.packages)
```

### Paging Search Results

You are able to page search results.

```dart
final results = await client.search('query');
final nextResults = await results.nextPage();
print(nextResults.packages)
```

If you want to retrieve a specific result page you can call the `page` parameter directly.

```dart
final results = await client.search('query',page:2);
print(results.packages)
```

Please file feature requests and bugs at the [issue tracker][tracker].

[tracker]: https://github.com/leoafarias/pub_api_client/issues
15 changes: 15 additions & 0 deletions analysis_options.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Defines a default set of lint rules enforced for
# projects at Google. For details and rationale,
# see https://github.com/dart-lang/pedantic#enabled-lints.
include: package:pedantic/analysis_options.yaml

# For lint rules and documentation, see http://dart-lang.github.io/linter/lints.
# Uncomment to specify additional rules.
# linter:
# rules:
# - camel_case_types

analyzer:
exclude:
- "**/*.g.dart"
- "**/*.freezed.dart"
Binary file added assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
20 changes: 20 additions & 0 deletions coverage_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions example/example.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
```dart
import 'package:pub_api_client/pub_api_client.dart';
void main() async {
final client = PubClient();
final packageInfo = await client.getPackage('fvm');
print('Package Info: $packageInfo');
}
```
6 changes: 6 additions & 0 deletions lib/pub_api_client.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/// Support for doing something awesome.
///
/// More dartdocs go here.
library pubdev_api;

export 'src/pub_api_client_base.dart';
18 changes: 18 additions & 0 deletions lib/src/models/package_score_model.dart
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import 'package:freezed_annotation/freezed_annotation.dart';

part 'package_score_model.freezed.dart';
part 'package_score_model.g.dart';

@freezed
abstract class PackageScore with _$PackageScore {
factory PackageScore({
final int grantedPoints,
final int maxPoints,
final int likeCount,
final double popularityScore,
final DateTime lastUpdated,
}) = _PackageScore;

factory PackageScore.fromJson(Map<String, dynamic> json) =>
_$PackageScoreFromJson(json);
}
Loading

0 comments on commit 32dbfe9

Please sign in to comment.