igdb_wrapper 1.0.2

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

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

with Flutter:


$ flutter packages get

Alternatively, your editor might support pub get or flutter packages 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

Analysis

We analyzed this package on Jul 13, 2018, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.0.0-dev.63.0
  • pana: 0.11.3

Scores

Popularity:
Describes how popular the package is relative to other packages. [more]
24 / 100
Health:
Code health derived from static analysis. [more]
99 / 100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100 / 100
Overall score:
Weighted score of the above. [more]
62
Learn more about scoring.

Platforms

Detected platforms: Flutter, web, other

No platform restriction found in primary library package:igdb_wrapper/igdb_wrapper.dart.

Suggestions

  • The description is too short.

    Add more detail about the package, what it does and what is its target use case. Try to write at least 60 characters.

  • Fix analysis and formatting issues.

    Analysis or formatting checks reported 1 hint.

    Run dartfmt to format lib/igdb_wrapper.dart.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.0.0-dev.55.0 <2.0.0
http ^0.11.3+16 0.11.3+17
Transitive dependencies
async 2.0.7
charcode 1.1.2
collection 1.14.10
http_parser 3.1.2
path 1.6.1
source_span 1.4.0
string_scanner 1.0.2
typed_data 1.1.5
Dev dependencies
test ^0.12.30