igdb_client 0.0.5

  • Readme
  • Changelog
  • Example
  • Installing
  • 51

igdb_client #

A Dart library for using the IGDB.com API v3 https://api-docs.igdb.com/

It is highly recommended to read through the IGDB documentation to understand what exactly you can do with the API.

Limitations #

Premium features (including IGDB user authentication) are not supported and I don't currently have plans to add support for them as I don't have access to these.

Usage #

To start using this, just add it to your pubspec:

pub package

See example/igdb_client_example.dart for a more in depth example of some of the things you can do with this client. Otherwise a simple example can be found below.

import 'package:igdb_client/igdb_client.dart';

var client = new IGDBClient(
  'your_user_agent',
  'your_api_key',
);

var gamesResponse = await client.games(new IGDBRequestParameters(
  limit: 3
));

print(IGDBClient.getPrettyStringFromMap(gamesResponse.toMap()));

if (gamesResponse.isSuccess()) {
  // do something with gamesResponse.data
}
else {
  // do something depending on gamesResponse.error
}

Changelog #

0.0.5 #

  • Updating for breaking change in http dependency
  • add support for alpha channel fo rimages

0.0.4 #

  • Added more endpoints and client methods for each
  • Added more platforms enums
  • Added IGDBHelper class for miscellaneous helper methods

0.0.3 #

  • Change IGDBRequestParameters.ids to a List

0.0.2 #

  • Update pubspec to appear as a Dart package instead of just a Flutter package

0.0.1 #

  • Initial version

example/igdb_client_example.dart

import 'api_key.dart';

import 'package:igdb_client/igdb_client.dart';

var client = new IGDBClient(
    MY_USER_AGENT,
    MY_API_KEY,
);

main() async {

  // Find games with 'infamous' in their name and return
  // the results' name and expand their release_dates and platforms.
  var gamesResponse = await client.games(new IGDBRequestParameters(
    search: 'infamous',
    fields: ['name', 'release_dates.*', 'platforms.*']
  ));
  printResponse(gamesResponse);

  // Find games that are not yet released but are releasing soon in the
  // North American, Worlwide, or Unspecified regions, then sort by 
  // release date.
  int msecSinceEpoch = DateTime.now().millisecondsSinceEpoch;
  int secsSinceEpoch = msecSinceEpoch~/1000;
  String timeNow = secsSinceEpoch.toString();
  var releaseResponse = await client.releaseDates(new IGDBRequestParameters(
    filters: 'date > $timeNow & (region = ${IGDBRegions.NORTH_AMERICA.id} | region = ${IGDBRegions.NONE.id} | region = ${IGDBRegions.WORLDWIDE.id})',
    order: 'date asc'
  ));
  printResponse(releaseResponse);

  var gameIdResponse = await client.games(new IGDBRequestParameters(
    ids: [43378],
  ));
  printResponse(gameIdResponse);
}

printResponse(IGDBResponse resp) {
  print(IGDBHelpers.getPrettyStringFromMap(resp.toMap()));
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  igdb_client: ^0.0.5

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:igdb_client/igdb_client.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
19
Health:
Code health derived from static analysis. [more]
92
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
70
Overall:
Weighted score of the above. [more]
51
Learn more about scoring.

We analyzed this package on Oct 16, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:igdb_client/igdb_client.dart with components: io.

Health suggestions

Fix lib/src/igdb_client.dart. (-3.45 points)

Analysis of lib/src/igdb_client.dart reported 7 hints, including:

line 9 col 1: Prefer using /// for doc comments.

line 23 col 3: Prefer using /// for doc comments.

line 30 col 22: Use ; instead of {} for empty constructor bodies.

line 32 col 3: Prefer using /// for doc comments.

line 55 col 9: Don't explicitly initialize variables to null.

Fix lib/src/igdb_response.dart. (-1.49 points)

Analysis of lib/src/igdb_response.dart reported 3 hints:

line 5 col 3: Prefer using /// for doc comments.

line 10 col 3: Prefer using /// for doc comments.

line 16 col 3: Prefer using /// for doc comments.

Fix lib/src/request_parameters.dart. (-1.49 points)

Analysis of lib/src/request_parameters.dart reported 3 hints:

line 47 col 27: Use isNotEmpty instead of length

line 54 col 24: Use isNotEmpty instead of length

line 58 col 28: Use isNotEmpty instead of length

Fix additional 9 files with analysis or formatting issues. (-1.50 points)

Additional issues in the following files:

  • lib/src/igdb_helpers.dart (2 hints)
  • lib/src/igdb_logger.dart (1 hint)
  • lib/igdb_client.dart (Run dartfmt to format lib/igdb_client.dart.)
  • lib/src/enums/endpoint.dart (Run dartfmt to format lib/src/enums/endpoint.dart.)
  • lib/src/enums/enums.dart (Run dartfmt to format lib/src/enums/enums.dart.)
  • lib/src/enums/genre.dart (Run dartfmt to format lib/src/enums/genre.dart.)
  • lib/src/enums/image_sizes.dart (Run dartfmt to format lib/src/enums/image_sizes.dart.)
  • lib/src/enums/platform.dart (Run dartfmt to format lib/src/enums/platform.dart.)
  • lib/src/enums/region.dart (Run dartfmt to format lib/src/enums/region.dart.)

Maintenance suggestions

The package description is too short. (-20 points)

Add more detail to the description field of pubspec.yaml. Use 60 to 180 characters to describe the package, what it does, and its target use case.

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0 <3.0.0
http ^0.12.0 0.12.0+2
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
http_parser 3.1.3
meta 1.1.7
path 1.6.4
pedantic 1.8.0+1
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6