Luisgolas.7046:

Making a simple query like this:
https://api.guildwars2.com/v2/items?ids=12452,12453,28445

returns an unexpected X-Result-Total:

X-Result-Count:3
X-Result-Total:41110

It’s not a big issue since I know that I’m querying for three items, so I know there will be three, and result-count is ok. But a little issue anyway. :p

smiley.1438:

I don’t see an issue here. Can you elaborate on this please?

http://wiki.guildwars2.com/wiki/API:2#Paging

X-Result-Total – The total number of resources.

Luisgolas.7046:

Maybe is a semantic question. X-Result-Total is the “The total number of resources.”, but, which resources? The resources I’m asking for? Or maybe the resources in general?

Maybe I’m wrong, but I understand that it should return the total number of items I’m querying, which is irrelevant in this simple example, but would make sense if I were paginating, since it would be the only way to know the total number before getting them all.

smiley.1438:

I think “resources” isn’t the best wording. X-Result-Total returns the total number of items which could be queried on that given endpoint (same as counting the array of numbers which you get when requesting without any parameters) – 41110 items in your case. The number of items in your query result is in X-Result-Count, obviously.

StevenL.3761:

It’s just saying that the response contains 3 objects out of 41110 known objects. I won’t argue its usefulness, but I wouldn’t call that result unexpected.

Related: https://github.com/arenanet/api-cdi/issues/15

One important thing to note is that X-Result-Count is not necessarily the number of requested items.

For example: https://api.guildwars2.com/v2/items?ids=12452,quack,28445

The request contains 3 identifiers, but the result count is 2.

darthmaim.6017:

The same happens when you request a page (?page=0&page_size=3), you request only 3 items but still want to know how many there are in total. page=x and ids=x are just used to specify which portion of all entries you want.

Luisgolas.7046:

I find strange that a request returns something I’m no querying about (the total number), instead of the number of items I’m requesting.

From my point of view it would be more consistent to return the total number requested since, like stevent pointed, this number could be unknown.

The same happens when you request a page (?page=0&page_size=3), you request only 3 items but still want to know how many there are in total. page=x and ids=x are just used to specify which portion of all entries you want.

In this case, you are requesting all the items, just paginating them. The problem would be if you paginate but you didn’t request all items: the X-Result-total wouldn’t be useful, unlike the not returned request’s total result of the query.

smiley.1438:

Just btw.: the response header is of informational character, not nessecarily part of the result.

Teranas.6150:

So basically adding a “X-Requested-Count” (something like that) would fit your need?

(Just to make this clear …)

I agree that the naming of “X-Result-Total” is kind of squishy but i wouldn’t change it without a really good reason (because of compatibility.)

Or do you want to remove it completely?

As you can see i’m a bit confused of the enitre thread

darthmaim.6017:

There is no difference between ids=1,2,3 and page=0&page_size=3, in both cases you are getting a subset of all total available items, X-Result-Count tells you how many you got in your queried result, X-Total-Count tells you how many there are in total.

I think that makes perfect sense and I’m not quite sure what your problem is exactly.

Lawton Campbell.8517:

It’s just saying that the response contains 3 objects out of 41110 known objects. I won’t argue its usefulness, but I wouldn’t call that result unexpected.

It’s useful if you’re using a language with manual memory management and want to pre-allocate space to unserialize the result objects :P

Maybe.

StevenL.3761:

Well, we use a stupid C# json framework that doesn’t allow specifying an initial capacity for collection types.

Lawton Campbell.8517:

Well, we use a stupid C# json framework that doesn’t allow specifying an initial capacity for collection types.

I’m using C99 — BYO collection types.

StevenL.3761:

That kinda looks like a car license plate.

niklas.1587:

Well, we use a stupid C# json framework that doesn’t allow specifying an initial capacity for collection types.

I’m using C99 — BYO collection types.

Horray for oldfashioned C!