Need help with Filters

Avatar image for mauryalamin
mauryalamin

50

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

#1  Edited By mauryalamin

I'm struggling with how to write a search query that filters for Publisher.

I want to search for Characters named "Hawkeye", that were "Male" and were published by "Marvel".

The following query returns male Marvel Hawkeyes, as well as a Hawkeye published by "20th Century Fox": https://comicvine.gamespot.com/api/characters/?api_key=<API KEY>&filter=name:hawkeye,gender:male,publisher:Marvel&format=json

Avatar image for kalel1938
kalel1938

11

Forum Posts

0

Wiki Points

0

Followers

Reviews: 0

User Lists: 0

The filters don't work on every field, only the ones that return a string, number or a date. The documentation doesn't make it clear which fields return objects or arrays. So for your case you can only filter on name and gender in your api call. Publisher returned in that call is a key-value object. And BTW gender is a numeric code. So your api call would be

https://comicvine.gamespot.com/api/characters/?api_key=<API KEY>&filter=name:hawkeye,gender:1&format=json

You'd then in your code have to filter publisher.name = Marvel of each object in the results array.