Skip to content
TORNLIFE More

Faction API: members list

Started by archimede [1565089] on in API Development.

14 replies · 397 views · thread synced · 5 days ago · View on torn.com
About this thread

Posts archived: 15 / 15 posts (100%) · the total is Torn's reply count + the opening post at the last fetch

Counted by TornLife from the archived posts.

Archived posts
15
Discussion span
→
People posting
5
Likes on archived posts
0
Authority score
52 / 100
Historical score
24 / 100
Story score
29 / 100
Engagement score
56 / 100
archimede [1565089]

Hi.

Experimenting with the API I noticed that members list is in the following format:


"members": { "70409": { "name": "J0E", "days_in_faction": "xxx" }, "237786": { "name": "DrZed", "days_in_faction": "xxx" },
...}
Would it be possible to change it to an array like

"members": [ {
"ID": 70409, "name": "J0E", "days_in_faction": "xxx" }, {
"ID": 237786, "name": "DrZed", "days_in_faction": "xxx" },...
]

?
archimede [1565089]

I see it is a recurring pattern. For example:
{ "donationnews": { "187288821": { "timestamp": "1449309337", "news": "<a href = "http://www.torn.com/profiles.php?XID=xxx">yyy</a> donated $70,523,111 to the faction" }, "187277232": { "timestamp": "1449285462", "news": "<a href = "http://www.torn.com/profiles.php?XID=zzz">www</a> donated 25 x Bottle of Beer to the faction" },...
}

Is there a compelling reason for not using arrays? It can be worked around, but isn't quite javascript-friendly.
McNeo [864688]

When you look for members it returns a list of members, represented by their id's. Then, it lists details about the member. I think this is a good way to represent it. If you need a list of members you can get just that without drilling any deeper.
archimede [1565089]

In my opinion what you call a "list" is technically an array: hence it should be placed in the corresponding data type. I fail to see what are the advantages of using an object instead...
McNeo [864688]

The way it is, if you want a member list (I mean, member array) you can. If you want more details of each member, then you drill one layer deeper. Making the change you mention would make more work to get a simple list of members.
McNeo [864688]

Right now if you were to query for a list of members it would return "70409,237786" - which is a list of members.

If they made the change you wanted, querying a list of members would result in "70409,J0E,xxx,237786,DrZed,xxx" - so yes, if you wanted a member list, it would be more work.

Plus, you'd couldn't do it your way, as you'd have duplicate keys. If you query "faction/members/name" how would it know which name to return? A faction of 100 members would have 100 values for "faction/members/name" so which one would it give you?

As it stands, everything is unique. You can query "faction/members/[unique player id]/name" to get the person's name.
archimede [1565089]

> querying a list of members would result in "70409,J0E,xxx,237786,DrZed,xxx"

I don't know what are you talking about.

My first post in this thread (which perhaps you should read again) refers to calls like:

http://api.torn.com/faction/1111?selections=basic&key=aaaaa
or
http://api.torn.com/faction/1111?selections=donationnewsfull&key=aaaaa

Both those call return two "lists" (members and donationnews respectively): all I'm saying is that those info should be arrays.

I hope it's more clear now.
McNeo [864688]

I see what you're saying with the array, given the [] tags instead of {}, but, I don't think you're seeing why this wouldn't work.

Even with your array, if you try to open it query for "ID", it has no idea which of 100 IDs you want, same with name and days in faction. It's all flat, there's nothing to make on entry unique form another, other than the value. But we can't search by value, presumably, because that's exactly what we're trying to look up.

With the current set up, if you dril to the list of members you get a list of IDs, which will all be unique, from there you can gain other information. This way, when you want someone's name, you need to say "ok, look in the faction area, then look in the members list, then look for this user id, then give me his/her name" and you can get the value.

With your method you would say "ok, look in the faction area, then look at the members list, then...." what? You can't just look for "name" because there is 100 names at the members level.
Mauk [1494436]

I completely agree with OP.

McNeo, I understand your confusion, but have no idea about how to clear it up. Sorry.
Mauk [1494436]

That's absolutely not the point. We all worked around it. They could send us data with every 'R' replaced with 'ILOVETHELETTERR' and we could "manage to make it work" very easily. It'd be stupid, but it'd be easy to work around.