igdb_wrapper 1.0.2

  • README.md
  • CHANGELOG.md
  • Example
  • Installing
  • Versions
  • 4

Build Status

api-dart

A Dart wrapper for the IGDB.com Free Video Game Database API.

About IGDB

One of the principles behind IGDB.com is accessibility of data. We wish to share the data with anyone who wants to build cool videogame oriented websites, apps and services. This means that the information you contribute to IGDB.com can be used by other projects as well.

Thus, you are not only contributing to the value of this site but to thousands of other projects as well. We are looking forward to see what exciting game related projects you come up with. Happy coding!

More info here:

Libraries

This wrapper uses three libraries for http requests.

Using your API key

  • Create a new APIWrapper Object by passing you 3Scale key, setting version (Pro or standard), and set isDebug (prints queries)
IGDBWrapper wrapper = new IGDBWrapper("YOUR_API_KEY", version: Version.STANDARD, debug: true);

Usage

All API endpoints are available as methods in the APIWrapper object. Each method has the following signature:

wrapper.endpoint(Parameters)

Arguments

  • Parameters - An object specifying the operations to be performed, ex. expander, filter, ordering etc. These Operations can be found in the API documentation under References: (https://igdb.github.io/api/references/)

Example

  • Requesting games from API
IGDBWrapper wrapper = new IGDBWrapper("YOUR_API_KEY", version: Version.STANDARD, debug: false);
params = new Parameters()
	.addFields("*")
	.addOrder("published_at:desc");
	
wrapper.games(params).then((result) => print("Response body: ${loaded.body}"));
// The sent request will look like this:
// https://api-endpoint.igdb.com/games/?fields=*&order=published_at:desc

The rest of the endpoints work similarly to the Games endpoint except for two cases presented bellow.

  • Requesting search from the API
IGDBWrapper wrapper = new IGDBWrapper("YOUR_API_KEY", version: Version.STANDARD, debug: false);
params = new Parameters()
	.addSearch("searchQuery")
	.addFields("*")
	.addOrder("published_at:desc");

wrapper.search(Endpoint.GAMES, params).then((result) => print("Response body: ${loaded.body}"));

// The sent request will look like this:
// https://api-endpoint.igdb.com/games/?search=searchQuery&fields=*&order=published_at:desc

The search endpoint need an extra parameter, Endpoint, as you can search any endpoint for information.

  • Filtering a request result
IGDBWrapper wrapper = new IGDBWrapper("YOUR_API_KEY", version: Version.STANDARD, debug: false);
params = new Parameters()
	.addFields("*")
	.addFilter("[themes][not_in]=42")
	.addOrder("published_at:desc");

wrapper.games(params).then((result) => print("Response body: ${loaded.body}"));

// The sent request will look like this:
// https://api-endpoint.igdb.com/games/?search=searchQuery&fields=*&filter[themes][not_in]=42&order=published_at:desc

Filtering requires extra information in the arguments and needs to be written out like in the example above. Information about Filtering and the postfixes like 'not_in' can be found here.

The rest of the available Endpoints are Available Here. The IGDB API documentation provides details on search parameters.

More examples

IGDBWrapper wrapper = new IGDBWrapper("YOUR_API_KEY", version: Version.STANDARD, debug: false);

//Search for up to two Atari platforms and return their names
params = new Parameters()
	.addSearch("Atari")
	.addFields("name")
	.addLimit("2");

wrapper.search(Endpoint.PLATFORMS, params).then((result) => print("Response body: ${loaded.body}"));

// The sent request will look like this:
// https://api-endpoint.igdb.com/platforms/?search=Atari&fields=name&limit=2

/*
Search for up to five Zelda games with release dates between 1 Jan and 31 Dec 2011, sorted by release date in descending order.
*/ 

params = new Parameters()
	.addSearch("Zelda")
	.addFields("name,release_dates.date,rating,hypes,cover")
	.addFilter("[release_dates.date][gt]=2010-12-31")
	.addFilter("[release_dates.date][lt]=2012-01-01")
	.addLimit("2")
	.addOffset("0")
	.addOrder("release_dates.date:desc");

wrapper.search(Endpoint.PLATFORMS, params).then((result) => print("Response body: ${loaded.body}"));

// The sent request will look like this:
// https://api-endpoint.igdb.com/games/?search=Zelda&fields=name,release_dates.date,rating,hypes,cover&filter[release_dates.date][gt]=2010-12-31&filter[release_dates.date][lt]=2012-01-01&limit=5&order=release_dates.date:desc


// Search for two specific games by their IDs


params = new Parameters()
	.addIds("18472,18228")
	.addFields("name,cover");

wrapper.games(params).then((result) => print("Response body: ${loaded.body}"));

// The sent request will look like this:
// https://api-endpoint.igdb.com/games/18472,18228?fields=name,cover

// Search for companies with 'rockstar' in their name. Return up to five results sorted by name in descending order

params = new Parameters()
	.addSearch("rockstar")
	.addFields("name,logo")
	.addFilter("[name][in]=rockstar")
	.addLimit("5")
	.addOffset("0")
	.addOrder("name:desc");

wrapper.search(Endpoint.COMPANIES, params).then((result) => print("Response body: ${loaded.body}"));

// The sent request will look like this:
// https://api-endpoint.igdb.com/companies/?search=rockstar&fields=name,logo&filter[name][in]=rockstar&limit=5&offset=0&order=name:desc */

Changelog

1.0.0

  • Initial version

example/lib/main.dart

import 'package:igdb_wrapper/igdb_wrapper.dart';

main() {
  final IGDBWrapper wrapper = new IGDBWrapper(
      "API_KEY",
      version: Version.STANDARD,
      debug: true);

  final p = new Parameters().addSearch("zelda");

  wrapper.games(p).then((result) => print("result body: ${result.body}"));
}

Use this package as a library

1. Depend on it

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


dependencies:
  igdb_wrapper: ^1.0.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

Alternatively, your editor might support 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_wrapper/igdb_wrapper.dart';
  
Version Uploaded Documentation Archive
1.0.2 Jun 28, 2018 Go to the documentation of igdb_wrapper 1.0.2 Download igdb_wrapper 1.0.2 archive
1.0.1 Jun 28, 2018 Go to the documentation of igdb_wrapper 1.0.1 Download igdb_wrapper 1.0.1 archive
1.0.0 Jun 28, 2018 Go to the documentation of igdb_wrapper 1.0.0 Download igdb_wrapper 1.0.0 archive
Popularity:
Describes how popular the package is relative to other packages. [more]
7
Health:
Code health derived from static analysis. [more]
0
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
0
Overall:
Weighted score of the above. [more]
4
Learn more about scoring.

The package version is not analyzed, because it does not support Dart 2. Until this is resolved, the package will receive a health and maintenance score of 0.

Analysis issues and suggestions

Support Dart 2 in pubspec.yaml.

The SDK constraint in pubspec.yaml doesn't allow the Dart 2.0.0 release. For information about upgrading it to be Dart 2 compatible, please see https://www.dartlang.org/dart-2#migration.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.55.0 <2.0.0