RandomAPI / Randomuser.me-old-source

[Deprecated] PHP source for Random User Generator - Please take a look at the new Node version
https://randomuser.me
137 stars 48 forks source link

Only the first user has a seed when requesting multiple users, and using that seed doesn't return the same user. #37

Closed mginnard closed 9 years ago

mginnard commented 9 years ago

Hey there!

When requesting multiple users, is there a way to find a per-generated-user seed to make a second call that only returns the first item in the results array?

If not, would it make sense to move seed outside of the first result in the results array?

Background — I'm making two calls to your API:

  1. This is a GET request for multiple users: https://www.runscope.com/public/03041da1-29a4-4d55-9f08-90098f078340/4c6b0d79-504f-4eed-9460-d24b35e59cdf
  2. And this uses the seed from the first result in the first call to (theoretically) fetch the first user in the list again: https://www.runscope.com/public/03041da1-29a4-4d55-9f08-90098f078340/03093baa-4b6b-4a10-85d1-6f681ba89155

Expected behavior: The seed in the first result would apply to only that randomly generated user, and making a subsequent call to /?seed={{seed}} would return that same first user.

Actual behavior: seed is included in the first item in the results array but applies to the entire list of results, rather than the first item. I couldn't find a per-generated-user seed in the response body when making a call like /?results=100.

intenseagile commented 9 years ago

I've just run across this as well.

The documentation ( (https://randomuser.me/documentation#seeds)) notes that

Seeds allow you to always generate the same user (or set of users)

Perhaps there could be a "per user" and "per results" seed?

mginnard commented 9 years ago

@intenseagile — Ah, just saw this in the closed issues: https://github.com/RandomAPI/Randomuser.me-Data/issues/26

Hopefully it's something that could change; I'd love to be able to use a per-user seed from a multiple user result, or just moving the per-result seed outside of the first item in the array since that feels like a bug.

keitharm commented 9 years ago

Hi @mginnard, @intenseagile

Yeah, #26 basically sums up why it currently isn't possible to implement a per user seed.

Actual behavior: seed is included in the first item in the results array but applies to the entire list of results, rather than the first item. I couldn't find a per-generated-user seed in the response body when making a call like /?results=100.

So the seed that is returned in the 1st result is the seed for regenerating that same set of users (with the same ?results=x parameter).

If you were to call the API with no parameters and then used the seed of that user to call the API again, it should return the same results.