TribesNext Profile and Clan API [BETA]

edited October 2018 in Support
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.
«13

Comments

  • edited October 2018
    Session API (https://tribesnext.thyth.com/tn/json/json_session.php):
    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
    • method: "login", "logout"
    • guid: account unique identifier
    • uuid: authenticated session identifier
    • un: account username
    • pw: account password
    • jsonp: callback function name

    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.
  • edited October 2018
    Browser API (https://tribesnext.thyth.com/tn/json/json_browser.php):
    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"}
  • This doesn't seem to be nearly as difficult as I initially thought when I made this post. At this point the only thing I'm really worried about is proper JSON parsing ingame (the Tourny script at a quick glance seems to be doing it in a rather hacky way), since everything else should be relatively trivial beyond that. But for that I'm pondering using some custom C++ code to provide a regex engine from something like Boost since it's pretty easy to have both TribesNext and 3rd party C++ coding operating at the same time.
  • For the Password or pw would it be the 3 part of the public.store? or would it be the actual player password non encrypted or anything?
  • I'm not sure how "direct password authentication over plaintext HTTP" can be interpreted any differently than "direct password authentication over plaintext HTTP". I also wouldn't have called attention to the complete lack of security if it was something else.

    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.
  • FF9
    edited May 2014
    i misread certain parts because of tiredness and i had DX help me out a bit... odd thing is trying to get the password into a global var at login so then it can be used to be put into the authentication of the session... i tried more of the logical ways of doing so for some reason i am unable to get the password though

    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
  • thanks Thyth for chiming in on things and everyone else for inspiration.

    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!

    ::)
  • Thanks for posting this stuff Thyth.

    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.
  • There is a roughly 5000 line of code implementation for in-game UIs that's nearly complete (the ones I showed off http://www.tribesnext.com/forum/index.php?topic=3132.0). I'll put together a git repo so people can look at it and contribute patches for remaining bugs/polish and the couple missing features.
  • There is a roughly 5000 line of code implementation for in-game UIs that's nearly complete (the ones I showed off http://www.tribesnext.com/forum/index.php?topic=3132.0). I'll put together a git repo so people can look at it and contribute patches for remaining bugs/polish and the couple missing features.

    Now we are talking, thanks again!

    :o
  • remember that this is more so of the finished product for the entire community to use...
  • http://tribes2stats.com/browser/
    I will periodically check here or this thread ( http://www.t2forums.com/index.php?topic=85.0 ) for feedback.
  • FF9
    edited May 2014
    Seems when you have switched the tribe name and tag in the creation page, seems you are unable to change your name in the profile
  • Alright, So I poked through a bit, Created a testing clan, and then messed around with settings and other stuff.

    Aside from the bug mentioned by F9 above, there's just a few formatting errors I'm seeing.

    Here's an example:
    Phantom139 set clan website to: "http://www.phantomdev.netquot;.
    

    Here's another one:
    append mode: 0^
    

    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.
  • Seems when you have switched the tribe name and tag in the creation page
    Actually, I don't think so. Maybe you expected them in a different order or something?
    seems you are unable to change your name in the profile
    You mean the player/account profile?

    Everything appears to be okay - did you notice an error message anywhere?
  • Seems when you have switched the tribe name and tag in the creation page
    Actually, I don't think so. Maybe you expected them in a different order or something?
    seems you are unable to change your name in the profile
    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:
    Name Change: error []
    
  • Okay, I'll have to look at that a little more. I don't know what the problem is right now.
    Alright, So I poked through a bit, Created a testing clan, and then messed around with settings and other stuff.

    Aside from the bug mentioned by F9 above, there's just a few formatting errors I'm seeing.

    Here's an example:
    Phantom139 set clan website to: "http://www.phantomdev.netquot;.
    

    Here's another one:
    append mode: 0^
    

    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.
    Thanks! Fixed both.
  • i mean that the T2 Tag and T2 Clan are switch meaning that the clan tag is the name of the clan and the clan name is the tag that is set.. i had to fix it manually in the settings since that seems to be working fine
  • i mean that the T2 Tag and T2 Clan are switch meaning that the clan tag is the name of the clan and the clan name is the tag that is set.. i had to fix it manually in the settings since that seems to be working fine
    I'm not trying to be difficult but I have created six tribes without any issue and no one else has reported this issue. I really think you just typed the name in the tag box. I just tried it again ( http://tribes2stats.com/browser/tribe.php?tid=201323 ) without issue.

    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?
  • {"status":"error","msg":"The player account rename feature is not currently available."}
    ^ That one might be Thyth and not me. =)
  • i mean that the T2 Tag and T2 Clan are switch meaning that the clan tag is the name of the clan and the clan name is the tag that is set.. i had to fix it manually in the settings since that seems to be working fine
    I'm not trying to be difficult but I have created six tribes without any issue and no one else has reported this issue. I really think you just typed the name in the tag box. I just tried it again ( http://tribes2stats.com/browser/tribe.php?tid=201323 ) without issue.

    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?

    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.
    Name Change: error [The player account rename feature is not currently available.]
    
  • {"status":"error","msg":"The player account rename feature is not currently available."}
    ^ That one might be Thyth and not me. =)
    Yeah, that's me. Final integration between account server and browser codebase is required for that feature -- just not quite there yet.
  • created clan and seems to be working :)
  • request invite option to join clan, not seeing how to do so, at a glance, or is it just me?

    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 isn't an option. With enough interest I might work some extras in like that but I want to make sure it isn't a duplicate effort as the stats are what I'm most interested in doing.
  • thanks Thyth for chiming in on things and everyone else for inspiration.

    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!

    ::)

    That sounds good. I'll keep my eye open so I can help promote this as things develop.
  • Any reason that this isn't on github (or some other git collab site)? Would love to contribute (and get back into this game).
  • I'm seeing a 403 forbidden error on tribes2stats.com. What is this sorcery?
  • Any reason that this isn't on github (or some other git collab site)? Would love to contribute (and get back into this game).
    It will be soon. I've committed to my local repo. I just haven't pushed yet.
  • Any reason that this isn't on github (or some other git collab site)? Would love to contribute (and get back into this game).
    It will be soon. I've committed to my local repo. I just haven't pushed yet.

    Waiting on Thyth to create the repo, as well.
Sign In or Register to comment.