Can't filter characters by gender

Avatar image for lordandrew
LordAndrew

14609

Forum Posts

98305

Wiki Points

0

Followers

Reviews: 0

User Lists: 36

#1  Edited By LordAndrew
 A request to a List Resource contains a resource name and an API Key. Optionally filters, sorting, and response format can be specified. Refer to the resource reference below for a list of fields that can be filtered and sorted. A request to retrieve all male characters sorted by birth_date in XML format would look like:
http://api.giantbomb.com/characters/?api_key=ABCDEF123456&gender=M&sort=birth_date&format=xml

That URL becomes easier to understand if broken apart. The "/characters/" path refers to the /characters/ resource. (See a complete list of resources below.)

The query string holds the rest of the request. The api_key parameter specifies your API key. The gender parameter specifies that the request should be filtered by gender. Passing "M" or "F" to it will filter the result set by either male- or female-only characters. Finally, the sort parameter specifies that the result set should be sorted by the "birth_date" field.

I tried this exact example, but it doesn't seem to work right. Both male and female characters are returned in the results.
I noted that male characters display a 1 instead of M for gender, and females display a 2 instead of F (contrary to the XML and JSON response examples). So I tried to use 1 and 2 in place of the M, but still no luck. Both male and female are shown regardless.
Avatar image for deactivated-60a279fd16d14
deactivated-60a279fd16d14

12

Forum Posts

4

Wiki Points

0

Followers

Reviews: 1

User Lists: 0

I've been messing around with this for a little while, too. The limit and offset are working fine, but I can't seem to get any other filtering or sorting to work.

It might help to note that I tried sorting /characters/ data. I tried filtering and sorting by gender, name, and real_name.
Avatar image for thebeast
thebeast

1920

Forum Posts

13373

Wiki Points

0

Followers

Reviews: 0

User Lists: 7

#3  Edited By thebeast

There are no advanced filtering options available in the current API it seems - the only filters available are 'limit' and 'offset' for list resources.

It would indeed be nice if we could pass any field as a parameter in order to use it as a filter - perhaps that would be too much load on the server, but it depends on whether a filter like that is more intensive than returning every single game in a list resource for the application to filter.

Edit: Looks like I'm wrong, the API docs are conflicting a bit - filters actually work as it says in the List Resource Requests section, but the actual subsections only mention limit and offset as filters.
Avatar image for andy
andy

445

Forum Posts

298

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

#4  Edited By andy
TheBeast said:
"There are no advanced filtering options available in the current API it seems - the only filters available are 'limit' and 'offset' for list resources.
It would indeed be nice if we could pass any field as a parameter in order to use it as a filter - perhaps that would be too much load on the server, but it depends on whether a filter like that is more intensive than returning every single game in a list resource for the application to filter.
"
We've purposefully decided to only allow specific fields to be filtered.  And you're right -- we haven't set any of those fields up yet.  Fortunately, it's as simple as me making a change to the config file, so it's really easy to do.

I'll spend some time today going through all the resources and making a list of things I think it would be cool to filter on.  I'll post that list here.
Avatar image for thebeast
thebeast

1920

Forum Posts

13373

Wiki Points

0

Followers

Reviews: 0

User Lists: 7

#5  Edited By thebeast
andy said:
"We've purposefully decided to only allow specific fields to be filtered.  And you're right -- we haven't set any of those fields up yet.  Fortunately, it's as simple as me making a change to the config file, so it's really easy to do.

I'll spend some time today going through all the resources and making a list of things I think it would be cool to filter on.  I'll post that list here."
Great stuff!
Will these filterable fields need exact values to match or is there support for wildcards etc.? Will the documentation be updated to show what values are expected?
Avatar image for andy
andy

445

Forum Posts

298

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

#6  Edited By andy
TheBeast said:
"andy said:
"We've purposefully decided to only allow specific fields to be filtered.  And you're right -- we haven't set any of those fields up yet.  Fortunately, it's as simple as me making a change to the config file, so it's really easy to do.

I'll spend some time today going through all the resources and making a list of things I think it would be cool to filter on.  I'll post that list here."
Great stuff!
Will these filterable fields need exact values to match or is there support for wildcards etc.? Will the documentation be updated to show what values are expected?
"
Docs will definitely be updated.  Right now we only support exact values.  I need to work out the syntax for wildcards or ranges (gt/lt/etc.).  I'm open to suggestions ;)
Avatar image for thebeast
thebeast

1920

Forum Posts

13373

Wiki Points

0

Followers

Reviews: 0

User Lists: 7

#7  Edited By thebeast

A few solutions I can think of:

name__contains=foo
name__startswith=foo
date__lt=01-01-2008
date__gt=01-01-2008

fname=:foo: - matches '*foo*'
fname=foo:: - matches 'foo*'
name = foo - matches 'foo'
fdate = 01-01-2008:01-01-2009 - matches between 01-01-2008 and 01-01-2009
(This ones rather ugly and is probably harder to parse...)

Dates could simply use 00 as a wildcard in any case - e.g. 00-00-2008 matches anything in 2008.
Avatar image for andy
andy

445

Forum Posts

298

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

#8  Edited By andy
TheBeast said:
"A few solutions I can think of:
name__contains=foo
name__startswith=foo
date__lt=01-01-2008
date__gt=01-01-2008

fname=:foo: - matches '*foo*'
fname=foo:: - matches 'foo*'
name = foo - matches 'foo'
fdate = 01-01-2008:01-01-2009 - matches between 01-01-2008 and 01-01-2009
(This ones rather ugly and is probably harder to parse...)

Dates could simply use 00 as a wildcard in any case - e.g. 00-00-2008 matches anything in 2008.
"
I'm partial to the first set... it's very Django-ish.

Avatar image for thebeast
thebeast

1920

Forum Posts

13373

Wiki Points

0

Followers

Reviews: 0

User Lists: 7

#9  Edited By thebeast
andy said:
"I'm partial to the first set... it's very Django-ish."
Yeah it does seem very Django-ish and I think it makes sense to have the filter in the attribute as opposed to the value.
Avatar image for bret
Bret

6

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 2

#10  Edited By Bret

I am also interested in some moderate filtering to build a couple apps I have in mind. Looks great and promising thus far tho. Thanks for this.

Avatar image for mrzwij
MrZwij

11

Forum Posts

1

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#11  Edited By MrZwij

Still getting the same results as the original poster - any update on when filtering will be working?

I'm super excited to start using this. It's a hell of a great thing you're doing here.

Avatar image for zerok
zerok

216

Forum Posts

223

Wiki Points

0

Followers

Reviews: 5

User Lists: 17

#12  Edited By zerok

Any update on this? Filtering on resource-lists would really be nice. Otherwise doing n queries for n releases there might exist for a game is bit much :-(

Avatar image for dmack
DMack

77

Forum Posts

164

Wiki Points

0

Followers

Reviews: 0

User Lists: 1

#13  Edited By DMack

Sorry for resurrecting a very old thread, but has there been any progress on this? The documentation uses this example:

http://api.giantbomb.com/characters/?api_key=ABCDEF123456&gender=M&sort=birth_date&format=xml

If I plug in my own API key, that example doesn't even work, Princess Zelda is among the first results returned. Any updates?

Avatar image for monk
Monk

187

Forum Posts

12

Wiki Points

0

Followers

Reviews: 1

User Lists: 1

#14  Edited By Monk

Sorry to resurrect this thread again but it seems the issue was never resolved.

Any update?

Avatar image for lordandrew
LordAndrew

14609

Forum Posts

98305

Wiki Points

0

Followers

Reviews: 0

User Lists: 36

#15  Edited By LordAndrew

@Monk said:

Sorry to resurrect this thread again but it seems the issue was never resolved.

Any update?

A newly redesigned site is on the horizon. I'm hoping it will include a greatly improved API, but I haven't heard anything about that.