Coder Social home page Coder Social logo

Comments (13)

krazyjakee avatar krazyjakee commented on July 28, 2024

I think you need this: https://igdb.github.io/api/references/expander/

from igdb-api-node.

Cohaven avatar Cohaven commented on July 28, 2024

That's awesome, but how do I use the wrapper with an expander?

from igdb-api-node.

dsibilly avatar dsibilly commented on July 28, 2024

The wrapper doesn't seem to have support for the expander functionality at this time. Should probably be put on the dev roadmap at some point if the intent is to keep 1:1 feature parity between the API and this module.

from igdb-api-node.

krazyjakee avatar krazyjakee commented on July 28, 2024

Sadly the expander cannot expand the platform in the release_date object directly but there is a workaround using the release_dates endpoint.

// {{api_url}}/release_dates/?fields=human,region,platform.name,game.name,game.cover.url&filter[game][eq]=38722&expand=platform,game
client.games({
  filters: {
    'game-eq': 38722
  },
  expand: ['platform', 'game'],
  limit: 50
}, [ 'human', 'region', 'platform.name', 'game.name', 'game.cover.url' ])
.then(response => { this.setState({ games: response.body }); })
.catch(error => { throw error; });

This is how it should work (in theory) but it's not implemented that way yet.

from igdb-api-node.

dsibilly avatar dsibilly commented on July 28, 2024

To clarify: the URL is how it can work now, but the JS code is how it should work if implemented in the wrapper module?

from igdb-api-node.

krazyjakee avatar krazyjakee commented on July 28, 2024

@dsibilly yes, exactly. Sorry for the confusion.

from igdb-api-node.

krazyjakee avatar krazyjakee commented on July 28, 2024

@Cohaven since it accepts any kind of parameter, this might actually work for you.

client.release_dates({
  filters: {
    'game-eq': 38722
  },
  expand: 'platform,game',
  limit: 50
}, [ 'human', 'region', 'platform.name', 'game.name', 'game.cover.url' ])
.then(response => { this.setState({ games: response.body }); })
.catch(error => { throw error; });

from igdb-api-node.

Cohaven avatar Cohaven commented on July 28, 2024

@krazyjakee I tried to use the example code you gave, but I get an error 400 when trying to execute the code.

This is the URL it seems to be generating:

https://igdbcom-internet-game-database-v1.p.mashape.com/release_dates/?filter[game][eq]=38722&fields=human,region,platform.name,game.name,game.cover.url&expand=platform,game&fields=human,region,platform.name,game.name,game.cover.url&limit=50&fields=human,region,platform.name,game.name,game.cover.url

Not sure why the fields are being triplicated.

from igdb-api-node.

dsibilly avatar dsibilly commented on July 28, 2024

There's no need to keep closing and reopening the issue.

@Cohaven, you've discovered a bug in the wrapper. I'll be looking into this tonight. Thanks for reporting it!

from igdb-api-node.

Cohaven avatar Cohaven commented on July 28, 2024

@dsibilly Sorry about the closing and reopening. I wasn't doing it on purpose. Wasn't paying attention to the meaning of the "Close and comment" button. Haven't done GitHub issue posts before.

No problem. Do you think it affects the ability of the code suggested by @krazyjakee to successfully use the expander?

from igdb-api-node.

dsibilly avatar dsibilly commented on July 28, 2024

I've submitted #20, which should fix the bug that duplicates the fields part of the URL query string. However, even with that fix in my local copy, I get the same HTTP 400 error you report:

Error: HTTP Status 400 - https://igdbcom-internet-game-database-v1.p.mashape.com/release_dates/?filter[game][eq]=38722&expand=platform,game&limit=50&fields=region,platform.name,game.name,game.cover.url
    at Request._callback (/Users/dsibilly/Projects/igdb-api-node/lib/perform-request.js:38:62)
    at Request.self.callback (/Users/dsibilly/Projects/igdb-api-node/node_modules/request/request.js:188:22)
    at emitTwo (events.js:106:13)
    at Request.emit (events.js:191:7)
    at Request.<anonymous> (/Users/dsibilly/Projects/igdb-api-node/node_modules/request/request.js:1171:10)
    at emitOne (events.js:96:13)
    at Request.emit (events.js:188:7)
    at IncomingMessage.<anonymous> (/Users/dsibilly/Projects/igdb-api-node/node_modules/request/request.js:1091:12)
    at IncomingMessage.g (events.js:292:16)
    at emitNone (events.js:91:20)

Also, the example code should use an Array for submitting the expand parameters:

client.release_dates({
    filters: {
        'game-eq': 38722
    },
    expand: [
        'platform',
        'game'
    ],
    limit: 50
}, [
    'region',
    'platform.name',
    'game.name',
    'game.cover.url'
]).then(response => {
    console.log(response.body);
}).catch(console.error);

EDIT: Oh, nevermind. The expand functionality doesn't seem to work for me at all. I get the following JSON response (as well as the HTTP 400 error) when i attempt the resulting URL directly with my API key:

{"status":400,"message":"Expander API is not available to the BASIC plan."}

So this may be the issue, perhaps?

from igdb-api-node.

krazyjakee avatar krazyjakee commented on July 28, 2024

Ok, so...

  • a hotfix for the fields issue has been published.
  • @dsibilly example above SHOULD work but expander functionality is currently limited to paid plans.
  • Expander and scroll API will be available to all plans (including free) before the end of August.

@Cohaven what prevents you from caching a conversion table?

from igdb-api-node.

krazyjakee avatar krazyjakee commented on July 28, 2024

Caching a conversion table is very much an acceptable solution for now.
Progress is being made on the expander. A complete list of expandable fields are listed here and it will continue to grow: https://igdb.github.io/api/references/expander/

from igdb-api-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.