Comments (13)
I think you need this: https://igdb.github.io/api/references/expander/
from igdb-api-node.
That's awesome, but how do I use the wrapper with an expander?
from igdb-api-node.
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.
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.
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.
@dsibilly yes, exactly. Sorry for the confusion.
from igdb-api-node.
@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.
@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.
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.
@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.
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.
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.
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)
- Unexpected token export in version 3.1.2 HOT 3
- Perform a vulnerability check
- .scrollAll returning HTTP 429 HOT 9
- Add the ability to get "count" and "meta" from endpoints
- Popular Games Feed HOT 2
- Handling error status with try catch function
- Problem getting filters applied HOT 2
- Add support for API3000 (v3) HOT 4
- 500 error on involied companies search HOT 2
- Unable to perform expanded filtered query. HOT 2
- Enabling CORS in React client HOT 2
- API Documentation not correct or not specified correctly on how to use the API! HOT 2
- Getting 400 Error Code HOT 1
- Finding the most popular/hot games currently HOT 1
- rename client-id with Client-ID in headers
- not getting ratings back in res
- Is Expand still a thing in this latest API? HOT 1
- Alternative names should be aliases when searching games
- Doesn't work. igdb() not a function error. HOT 1
- How to write Multi-Query
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from igdb-api-node.