TribesNext Profile and Clan API [BETA]
I spent a couple of hours shaking out cobwebs and skeletons from the unfinished TribesNext community backend system. This is the system responsible for managing clans, tags, player profiles, and so forth. The implementation was mostly complete 2 years ago, but not fully stable or fully abuse resistant. The remaining blocker issues to general availability have been resolved now.
I won't have time any time in the near future (or ever?) to complete the in-game UIs for T-Mail or player/clan browser -- if you're interested, capable, and would like to take on the task, you're welcome to try.
This is a "beta" release of JSON APIs covering password based authentication (over plaintext HTTP-- oh my!), and all of the APIs required to create and manage clans and user profiles within the TribesNext system. I made use of these APIs by hand when managing the first three or four seasons of the Draft League tournaments (before moving on to assorted level of completeness in-game UIs). The API endpoints support JSONP to permit bypassing cross origin policy restrictions if you would like to build an alternative UI for yourself.
Endpoints are as follow:
https://tribesnext.thyth.com/tn/json/json_session.php -- this is responsible for password authentication methods
https://tribesnext.thyth.com/tn/json/json_browser.php -- this provides browser APIs once an authenticated session is established
Source code to both endpoints in PHP can be viewed:
https://tribesnext.thyth.com/tn/json/json_session.phps
https://tribesnext.thyth.com/tn/json/json_browser.phps
This source code should be sufficient information to get started. I'll write more complete documentation as time allows later.
To have a visible clan tag in game, you will need to download and install the in-game community stub script used for the Draft League tournaments: https://tribesnext.thyth.com/tn/tournamentNetClient2.zip
Be advised that these endpoints may change or become inactive without warning. If people actually start using them, I may move them to a tribesnext.com subdomain. Also, there are certain policy restrictions on the number of times an account will be able to issue certain types of requests in a time period (esp. new clan creation).
All TN accounts should be able to authenticate against this endpoint now that the account and community services have been integrated.
Enjoy.
I won't have time any time in the near future (or ever?) to complete the in-game UIs for T-Mail or player/clan browser -- if you're interested, capable, and would like to take on the task, you're welcome to try.
This is a "beta" release of JSON APIs covering password based authentication (over plaintext HTTP-- oh my!), and all of the APIs required to create and manage clans and user profiles within the TribesNext system. I made use of these APIs by hand when managing the first three or four seasons of the Draft League tournaments (before moving on to assorted level of completeness in-game UIs). The API endpoints support JSONP to permit bypassing cross origin policy restrictions if you would like to build an alternative UI for yourself.
Endpoints are as follow:
https://tribesnext.thyth.com/tn/json/json_session.php -- this is responsible for password authentication methods
https://tribesnext.thyth.com/tn/json/json_browser.php -- this provides browser APIs once an authenticated session is established
Source code to both endpoints in PHP can be viewed:
https://tribesnext.thyth.com/tn/json/json_session.phps
https://tribesnext.thyth.com/tn/json/json_browser.phps
This source code should be sufficient information to get started. I'll write more complete documentation as time allows later.
To have a visible clan tag in game, you will need to download and install the in-game community stub script used for the Draft League tournaments: https://tribesnext.thyth.com/tn/tournamentNetClient2.zip
Be advised that these endpoints may change or become inactive without warning. If people actually start using them, I may move them to a tribesnext.com subdomain. Also, there are certain policy restrictions on the number of times an account will be able to issue certain types of requests in a time period (esp. new clan creation).
All TN accounts should be able to authenticate against this endpoint now that the account and community services have been integrated.
Enjoy.
Comments
In order to use the browser APIs, you must first establish an authenticated session with the system. For the JSON API, the only currently supported method is with a direct password authentication over plaintext HTTP. The T2 targeted "robot" API is capable of doing an RSA key challenge response with an account key; see the tournamentNetClient.zip for the script implementation of this method if you would like to initialize sessions without transmitting plaintext credentials. If there is demand, I will expose access to these capabilities to the JSON side. Sessions initialized via "robot" API and JSON API are equivalent once established -- you can alternatively extract the session ID variable from a T2 authenticated instance for use as the "uuid" parameter.
The API responds to all HTTP methods (GET/POST/etc.) effectively equivalently. I suggest using POST method and form encoding of the request parameters to avoid accidental transmission of the session identifier in referrer fields.
Accepted request parameters
Parameter Table
method=Required parameters:Successful output:Failed output:
loginun, pw{"status":"success","guid":,"uuid":,"message":"logged in"}{"status":"error","message":}
logoutguid, uuid{"status":"success"}
Looks like the TribesNext forum style is stripping table borders. Copy/paste to another HTML document for enhanced readability.
Once you have initiated an authenticated session with the system, you can invoke requests against the browser API.
Accepted request parameters
- method:
- guid: account unique identifier
- uuid: authenticated session identifier
- payload: JSON encoded method parameters
- jsonp: callback function name
The output of most methods is nearly identical.On successful invocation, you will get: {"status": "success"}
On failed invocation, you will get: {"status": "error", "msg": }
The output example is only specified if the method output deviates from these possibilities.
Parameter Table
method=Description:Payload example:Output example:
clansearchSearch for clans by name.{"q":"name"}[{"id": "clanid", "name": "clan name"}]
clanviewView clan details, suitable for showing a clan profile page.{"id":"numeric clan id"}
{"id":"clanid", "name": "clan name", "tag": "clan tag", "append": "tag at end of name?",
"recruiting": "clan recruiting?", "website": "clan website", "info": "clan profile page text",
"creation": "UNIX timestamp for clan creation time", "picture": "in-game picture shown in profile",
"active": "whether or not this clan is active or abandoned/disbanded"
"members": [{"guid":"member GUID", "name":"member name", "tag":"member's active tag",
"append":"member's tag at end of name?", "rank": "member's rank in this clan",
"title": "member's title in this clan", "online": "player is currently online?"}]}
clanhistoryView clan audit history.{"id":"numeric clan id"}
clanrecruitSet clan recruiting status.{"id":"clan ID","v":"true/false recruitment status"}
claninfoSet the clan browser page info.{"id","clan ID","v","Text for the clan's info page."}
clantagSet the tag on a clan.{"id":"clan ID","tag":"tag string","append":"true/false boolean controlling tag at start/end of name"}
clansiteSet the clan website.{"id":"clan ID","v":"www.example.com"}
clannameRename a clan.{"id":"clan ID","v":"New Clan Name"}
clanpictureSet which picture is used on the clan info page for the in-game GUIs.{"id":"clan ID","v":"path/to/in-game-img.png"}
claninviteSend an invitation to join the clan to another player.{"id":"clan ID","to":"invitee GUID"}
clanviewinvitesView outstanding invites to a clan.{"id":"clan ID"}
{"status": "success", "payload":
[{"sender": {"guid": "sender GUID", "name": "sender name", "tag": "sender tag", "append": "append tag?"},
"recipient": {"guid": "invitee GUID", "name": "invitee name", "tag": "invitee tag", "append": "append tag?"},
"expire": "UNIX timestamp for invitation expiration"}]}
clanrankChange rank/title of a player in a clan. Can be on self.{"id":"clan ID","to":"target GUID","rank":"integer 0 to 4","title":"Text Title in Clan"}
clankickKick a player from a clan.{"id":"clan ID","to":"kickee"}
clandisbandAuthorize disband of a clan, or retract that authorization (if the clan is still around).{"id":"clan ID","v":"yes/no disband authorization status"}
usersearchSearch for players by name.{"q":"player name"}[{"guid":"account GUID", "name":"player name", "tag":"player active tag", "append":"tag at end?"}]
userviewView user details, suitable for showing a user profile page.{"id":"account GUID"}
{"guid":"account GUID", "name": "player name", "tag": "active tag", "append": "tag at end of name?",
"creation": "UNIX timestamp of account creation", "website": "player's website", "info": "Player profile text..."
"online": "is player online?", "memberships": [{"id":"clanid","name":"clan name","rank":"clan rank",
"title":"clan title", "tag","tag of clan", "append":"is clan's tag appended?"}]}
userhistoryView user audit history.{"id":"account GUID"}
usernameRequest an account name change. {"name": "New desired account name"}
userclanSet which clan tag is active. Client must be a member of a clan to set the tag. Supplying -1 will set no active tag.{"id", "clanid or -1"}
usersiteSet player profile website link.{"site": "www.example.com"}
userinfoSet player profile page text contents.{"info": "Profile page contents..."}
userinvitesGet a list of invitations for this player.
[{"sender":{"guid":"inviter GUID", "tag": "inviter tag", "append": "inviter tag append?",
"name": "inviter name"}, "clan":{"name": "clan name", "id": "clanid", "tag": "clan tag",
"append": "clan tag appended?"}, "expire":"UNIX timestamp for when invitation expires"}]
useracceptAccept a clan join invitation.{"id": "clanid from the invitation"}
userrejectDecline a clan join invitation.{"id": "clanid from the invitation"}
userleaveLeave a clan.{"id", "clanid to leave"}
createclanCreate a new clan.{"tag": "desired clan tag", "append": "yes/no/true/false", "name": "desired clan name", "recruiting": "yes/no/true/false", "info": "initial clan profile page"}
If you're interested in producing an in-game client, you'll likely want to use the "robot" API instead of the JSON API. Parsing JSON will not be a fun exercise in T2 script, and the "robot" API produces a line oriented regular data format more amenable to parsing with the limited string processing capabilities exposed by the game. Get in touch with me directly if you want to go that route.
EDIT: nvm i got it took some time and effort and major brain farts to figure out that i needed to delete the dso files in the T2csri.vl2 oh well at least it works now
Some reason I missed notifications for this thread..checked now.
I need to review thread, as it looks encouraging at a glance.
We are planning some new tourneys now for cash, to get the revival started!
::)
I have working web interface with login/logout. I'll go ahead and add the other features in and then maybe someone else can look about doing it in-game. I doubt I have the time to grind through crappy T2 code.
Now we are talking, thanks again!
I will periodically check here or this thread ( http://www.t2forums.com/index.php?topic=85.0 ) for feedback.
Aside from the bug mentioned by F9 above, there's just a few formatting errors I'm seeing.
Here's an example:
Here's another one:
Everything else appears to be functioning as it should. I'll keep poking around a bit to see if there's anything that's doing what it shouldn't do.
You mean the player/account profile?
Everything appears to be okay - did you notice an error message anywhere?
What he means is the segment under the account information page where you can set the player name.
When you try to change the name you get the following:
Thanks! Fixed both.
I have added logging to both the player name change and the tribe creation to help me figure this out.
I also fixed the success/error message display so that you can see the actual message.
Can you please try again for me?
^ That one might be Thyth and not me.
Looks like you need to add it to the list of currently not available features. Otherwise you've got a code block in there that has this turned off.
thanks again thyth and Teratos and everyone else who has helped make this happen....noticed Sylock already got a clan and I hope to see the assasins in the Tourney coming up, as that is one team, I offered to sponsor and pay the entry fee for, as like to make sure we got some strong teams out there and bring in some contenders...
Check forums here for briefing on tourney http://www.tribesnext.com/forum/index.php?topic=3342.0
That sounds good. I'll keep my eye open so I can help promote this as things develop.
Waiting on Thyth to create the repo, as well.