Package: pycftools
pycftoolsThis library provides access to all cftools api methods. It is a kind of wrapper for all methods.https://developer.cftools.cloud/documentation/data-apiFor each library method. A verbose docstring has been written.Installationpip install pycftoolsBasic usage:importpycftoolscfapi=pycftools.CfToolsApi(app_id='',app_secret='',game_identifier='',ip='',game_port='',server_id='',server_banlist_id='')Constructor argumentsClassCfToolsApiusedtoaccessvariouscftoolsapimethods.Themainuse,gettingaccesstoapi.Theabilitytoautomatesomeprocesses,andgettingaccesstotheapplicationfromoutside.:paramapp_id:ApplicationIdfromhttps://developer.cftools.cloud/applications:typeapp_id:str:paramapp_secret:Applicationsecretfromhttps://developer.cftools.cloud/applications:typeapp_secret:str:paramgame_identifier:Game_identifierisneededtocreateserverid.:typegame_identifier:str:paramip:Ipv4isneededtocreateserverid.:typeip:str:paramgame_port:Game_portisneededtocreateserverid.:typegame_port:str:paramserver_api_id:Server_api_idthisistheglobalserveridentifieranditcanbefoundintheserverAPIsettings.:typeserver_api_id:str:paramserver_banlist_id:Server_banlist_idisglobalbanlistidentifier,itcanbefoundinban-managerhttps://app.cftools.cloud/ban-manager-seeforBanlistID.:typeserver_banlist_id:str:paramauth_token_filename:Auth_token_filenamethisisthefilenamevarforauthtokenfile.:typeauth_token_filename:str:parampycftools_debug:Thisisthevariableforenablingdebugoutputsfromtheprogram.:typepycftools_debug:bool:paramtimestamp_delta:Thisisthetimeoffsetdeltawhenthetokeninthefileneedstobeupdated.Bydefault,thevalueissettohalfaday-43200.UNIXTIMESTAMP:typetimestamp_delta:intMethodsThe library provides all the methods from the cftools documentation.
Request parameters are completely identical to those presented in the documentation.All methods of the class return response objects, this is done for the convenience of further control.You need to work with them as with ordinary responses to requests. json(), text, status_code, etc...If you don't know how to work with response objects. Read the documentation for the requests module.Authenticationcfapi=pycftools.CfToolsApi(--->...<---)# Before working with methods, you need to get a token# The library itself will add the token to the session headers# All you need to do is create an instance of the class with all the parameters.AuthAfter version 0.2.7, you no longer need to call this method yourself.The library will do everything by itself when you call the method you need.check_register()Thismethodisneededtocheckifwehaveanup-to-dateauthorizationtoken.Itchecksifthereisafilewithatokeninside.Ifsuchisfound,itcheckstherelevanceofthetokenandloadsifeverythingiscorrect.Note:Savingatokentoafileisthesimplestthingthatcametomymind.Perhapsthereissomekindofsecuritythreatfromthis.Writetoissuesongithubtodiscuss:)Savingthetokentoafilemakesitpossiblenottorequestanewtoken-everytimeaftertheobjectisre-created.Moreover,thereisadelayof2requestsperminute.:return:returnTrueifallauthmomentsisOK.elseFalse.:rtype:boolGrant process and access permissions[GET]grants()Getlistofallgrantsandtheirrespectiveid's.Note:MAXREQUESTS:1/MINUTE:return:Listofallgrantsandtheirrespectiveid's.:rtype:ResponseGame-Server# The library itself creates the serverID (sha1 -> hexdigest) from the game id, ipv4, gameport[GET]server_details()GetserverdetailsbyServerId.Serveridserveridisspecifiedintheclassconstructor.:return:ServerdetailsbyServerId.:rtype:ResponseServer[GET]server_info()Getgeneralinformationabouttheregisteredserver.:return:Informationabouttheregisteredserver:rtype:Response[GET]server_statistics()Getserverstatistics.:return:Serverstatistics.:rtype:Response[GET]server_player_list()Getfullplayerlist.:return:Fullplayerlist.:rtype:Response[POST]server_kick(gs_id,reason)# gamesession_id, reason. -> strKickaplayer.:paramgs_id:Anactivegamesession_id(Seecftools_api_get_server_list()fordetails):typegs_id:str:paramresaon:Reason1-128lenmax.:typeresaon:str:return:Returns204onsuccess.:rtype:Response[POST]server_private_message(gs_id,content)# gamesession_id, content. -> strSendaprivatemessagetoaplayer.:paramgs_id:Anactivegamesession_id(Seecftools_api_get_server_list()fordetails):typegs_id:str:paramcontent:Messagecontentlength:1-256.:typecontent:str:return:Returns204onsuccess.:rtype:Response[POST]server_public_message(content)# content -> strSendapublicmessagetotheserver.:paramcontent:Messagecontentlength:1-256.:typecontent:str:return:Returns204onsuccess.:rtype:Response[POST]server_row_rcon_command(command)# command -> strSendarawRConcommandtotheserver.:paramcommand:Commandlength:1-256.:typecommand:str:return:Returns204onsuccess.:rtype:Response[POST]server_teleport(gs_id,coords)# gamesession_id -> str, coords -> [X,Y] -> listTeleportaplayerGameLabsrequiredNotallgamessupported.:paramgs_id:Anactivegamesession_id(Seecftools_api_get_server_list()fordetails):typegs_id:str:paramcoords:Coordinateslist{2}:[X,Y]:typecoords:list:return:Returns204onsuccess.:rtype:Response[POST]server_spawn(gs_id,obj_name,quantity)# gamesession_id, obj_name -> str, quantity -> intSpawnanobjectforplayerGameLabsrequiredNotallgamessupported.:paramgs_id:Anactivegamesession_id(Seecftools_api_get_server_list()fordetails):typegs_id:str:paramobj_name:Objectstring.:typeobj_name:str:paramquantity:Quantity1-9999Highquantitieswilllagaserver.:typequantity:int:return:Returns204onsuccess.:rtype:Response[GET]server_queue_priority_list(cftools_id,comment)GetalistofallqueuepriorityentriesStreamedresponse.:paramcftools_id:CFToolsID:typecftools_id:str:paramcomment:Commentstring.:typecomment:str:return:Listofallqueuepriorityentries.:rtype:Response[POST]server_queue_priority_entry(cftools_id,expires_at,comment)Createanewqueuepriorityentry.:paramcftools_id:ACFToolsaccountid.:typecftools_id:str:paramexpires_at:Expirationdatetimeobjectornull;Nullisapermanententry.:typeexpires_at:str:paramcomment:Anoteorcomment.:typecomment:str:return:Returns204onsuccess.:rtype:Response[DELETE]queue_priority_delete_entry(cftools_id)Deleteanexistingqueuepriorityentry.:paramcftools_id:ACFToolsaccountid.:typecftools_id:str:return:Returns204onsuccess.:rtype:Response[GET]server_whitelist(cftools_id,comment)GetalistofallwhitelistentriesStreamedresponse.:paramcftools_id:CFToolsID:typecftools_id:str:paramcomment:Commentstring.:typecomment:str:return:Listofallwhitelistentries.:rtype:Response[POST]server_whitelist_entry(cftools_id,expires_at,comment)Createanewwhitelistentry.:paramcftools_id:ACFToolsaccountid.:typecftools_id:str:paramexpires_at:Expirationdatetimeobjectornull;Nullisapermanententry.:typeexpires_at:str:paramcomment:Anoteorcomment.:typecomment:str:return:Returns204onsuccess.:rtype:Response[DELETE]server_whitelist_delete_entry(cftools_id)Deleteanexistingwhitelistentry.:paramcftools_id:ACFToolsaccountid.:typecftools_id:str:return:Returns204onsuccess.:rtype:Response[GET]server_leaderboard(stat,order,limit)Requestthegenerationofaleaderboardbasedoninternallykeptplayerstats.Thismayfailifnostatsarepresent.Note:MAXREQUESTS:7/MINUTE:paramstat:Oneofkillsdeathssuicidesplaytimelongest_killlongest_shotkdratio:typestat:str:paramorder:1(Ascending)or-1(Descending):typeorder:int:paramlimit:Anintegerbetween1and100;Defaultsto10:typelimit:int:return:Leaderboardbasedoninternallykeptplayerstats.:rtype:Response[GET]server_player_stats(cftools_id)Individualstatsofaplayerforaserver.Note:MAXREQUESTS:10/MINUTE:paramcftools_id:ACFToolsaccountid.:typecftools_id:str:return:Individualstatsofaplayer.:rtype:ResponseBanlist[GET]server_banlist(flt)Getalistofallbans.Streamedresponse.:paramflt:EitheranIPv4oraCFToolsaccountid:typeflt:str:return:Listofallbans.:rtype:Response[POST]server_ban(frmt,identifier,expires_at,reason)Issueanewban.Triggersanin-gamekick.:paramfrmt:cftools_idoripv4.:typefrmt:str:paramidentifier:ACFToolsaccountidoranIPv4;IPv4maycontainwildcardsubstitutesinformofanasteriks.:typeidentifier:str:paramexpires_at:Expirationdatetimeobjectornull;Nullisapermanententry.:typeexpires_at:str:paramreason:Abanreason,:typereason:str:return:Returns204onsuccess.:rtype:Response[DELETE]server_unban(ban_id)Revokeanexistingban.:paramban_id:Thebanidofanexistingban:typeban_id:str:return:Returns204onsuccess.:rtype:ResponseUsers[GET]server_lookup_user(identifier)SearchCFToolsClouddatabaseforauser.:paramidentifier:EitheraSteam64,BattlEyeGUIDorBohemiaInteractiveUID:typeidentifier:str:return:Jsonresponsewithinformationaboutuser.:rtype:ResponseIf u needed to close sessioncfapi.close()Methodtocloseasession.