{"id":24793081,"url":"https://github.com/zhenglinlei/tkapi","last_synced_at":"2025-07-27T06:10:05.103Z","repository":{"id":135115399,"uuid":"376841082","full_name":"ZhengLinLei/TkAPI","owner":"ZhengLinLei","description":"API bot for tik tak toe game","archived":false,"fork":false,"pushed_at":"2021-06-14T16:41:22.000Z","size":27,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-24T17:05:08.560Z","etag":null,"topics":["bot","game","javascript","tiktaktoe"],"latest_commit_sha":null,"homepage":"https://zhenglinlei.github.io/TkAPI/","language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZhengLinLei.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-06-14T13:54:45.000Z","updated_at":"2023-07-27T11:38:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"93c43baa-221b-4dca-a8b8-de3c77820b2b","html_url":"https://github.com/ZhengLinLei/TkAPI","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ZhengLinLei/TkAPI","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FTkAPI","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FTkAPI/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FTkAPI/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FTkAPI/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZhengLinLei","download_url":"https://codeload.github.com/ZhengLinLei/TkAPI/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZhengLinLei%2FTkAPI/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267312382,"owners_count":24067788,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-27T02:00:11.917Z","response_time":82,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bot","game","javascript","tiktaktoe"],"created_at":"2025-01-29T21:55:53.070Z","updated_at":"2025-07-27T06:10:05.033Z","avatar_url":"https://github.com/ZhengLinLei.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eTkAPI Bot - Tik Tak Toe Bot\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ci\u003eTkAPI is a library API Bot where you make the the Tik Tak Toe Game easily with this bot\u003cbr\u003e using Typescript/JavaScript and other languages.\u003c/i\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n    \u003cb\u003eThis is a bot not an AI\u003c/b\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"./CONTRIBUTING.md\"\u003eContributing\u003c/a\u003e\n  ·\n  \u003ca href=\"https://github.com/ZhengLinLei/TkAPI/issues\"\u003eIssues\u003c/a\u003e\n\u003c/p\u003e\n\n\u003cp align=\"center\"\u003e\n  \u003ca href=\"https://opensource.org/licenses/Apache-2.0\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/License-Apache%202.0-blue.svg\" alt=\"TkAPI License\" /\u003e\n  \u003c/a\u003e\u0026nbsp;\n  \u003ca\u003e\n    \u003cimg src=\"https://img.shields.io/badge/version-1.0-brightgreen\" alt=\"TkAPI Version\" /\u003e\n  \u003c/a\u003e\u0026nbsp;\n  \u003ca\u003e\n    \u003cimg src=\"https://img.shields.io/badge/size-4kb-yellow\" alt=\"TkAPI Size\" /\u003e\n  \u003c/a\u003e\n\u003c/p\u003e\n\n\u003chr\u003e\n\n\nA example website [here](https://zhenglinlei.github.io/TkAPI/tutorial/)\n\n\n\n## Index\n\nLearn how to use this library\n\n- [Content](#content)\n- [Getting Started](#gettingstarted)\n- [Examples](#examples)\n- [Extension](#extension)\n\n\n## \u003ca name=\"content\"\u003e\u003c/a\u003e Content\n\nBefore getting started to your tik tak toe game it is necessary to know what includes in this repository.\n\nYou can view code examples in `./tutorial` folder, and the source code in `./src` folder. The minified project files are in the `./min` folder where includes two files:\n\n*Main file*\n``\n./min/tkapi.min.js\n``\n\n**Extension file**\n\n_This file is an extension from the main file. If you want to create an easy and fast view, we have the solution for you. For the documentation [here](#extension)_\n``\n./min/tkapiGui.min.js\n``\n\n\n## \u003ca name=\"gettingstarted\"\u003e\u003c/a\u003e Getting Started\n\n#### Guide\n\n**Properties**\n- [class.options](#class.options)\n\n\n**Method**\n- [class.getResponse(:int)](#class.getResponse)\n- [class.getHistory()](#class.getHistory)\n- [class.getSimplyUI()](#class.getSimplyUI)\n- [class.getWinner()](#class.getWinner)\n- [class.reset()](#class.reset)\n\n\n**Unfortunately we do not have a CDN, but you can clone the repo and use it in local**\n\n### 1. Firstly add the script to your project\n\n```html\n\u003cscript src=\"./min/tkapi.min.js\"\u003e\u003c/script\u003e\n```\n\nAnd if you want to use the auto make default UI view add this script before the main file\n```html\n\u003cscript src=\"./min/tkapiGui.min.js\"\u003e\u003c/script\u003e\n```\n\n\n### 2. Create a varible with the class\n\n_Here we are going to learn how to use only the main class, if you want to read the extension documentation click [here][#extension]_\n\n\nIn your JS file or inner script tag\n```javascript\nconst TKAPI = new TkApi();\n```\n\nThe object require options, if you do not pass anything the bot use the defaults options.\nAll this options can be changed in process, with the property of the class `class.options` replacing the class to your variable name.\n```javascript\n{\n\n    symbol: {\n\n        // Symbol used for simply UI if you want to personalizate it; Options (x | 0) :Default | Str\n\n        bot: \"x\",\n        user: \"o\"\n    },\n\n    botType: \"Bot\", // Options \"Bot\" :Default | \"Random\"\n\n    speed: 5 // Options in ms, miliseconds 5 :Default | Int \u003e 0; This is for a synchronous pause when the bot response\n\n}\n```\n\n\n### 3. \u003ca name=\"class.options\"\u003e\u003c/a\u003e Change the options\n\nYou can change the options with `class.options` property\n```javascript\nTKAPI.options = {\n    symbol: {\n        bot: \"-\",\n        user: \"*\"\n    },\n    botType: \"Random\",\n    speed: 5\n}\n```\n\n\n### 4. \u003ca name=\"class.getResponse\"\u003e\u003c/a\u003e Making a request to the bot [ class.getResponse(:int) ]\n\nThe `class.getResponse(:num)` is a conection between user and bot, need one parameters and must be a number between 0 to 8, logically the 8 positions avalibales in the tik tak toe table.\n\nAfter you call this method with the position where the user want to put the token in the table, the bot returns a number, and it is the position of the table where the bot chose.\n\nIf you pass a not empty position, the bot returns an error\n```javascript\nTKAPI.getResponse(4);\n```\n\nYou can save the the value in a variable and then use it\n```javascript\nlet botNumberPosition = TKAPI.getResponse(4);\n\nconsole.log(botNumberPosition);\n// Output: Int\n//\n// 2\n```\n\n\n### 5. \u003ca name=\"class.getHistory\"\u003e\u003c/a\u003e Get the game history [ class.getHistory() ]\n\nIf you want to check the history of the game you can use `class.getHistory()`, and it will return an object\n```javascript\nlet historyGame = TKAPI.getHistory();\n\nconsole.log(historyGame);\n//Output: Object\n//\n//  {\n//      user: [0, 1],\n//      bot: [2],\n//      round: 2\n//  }\n```\n\n\n### 6. \u003ca name=\"class.getSimplyUI\"\u003e\u003c/a\u003e Get a simply status view [ class.getSimplyUI() ]\n\nWhen you are debugging or you want to view the status, you can call this function to get the interface of the game in the console\n```javascript\nTKAPI.getSimplyUI();\n\n//Output: Str\n//\n//  ___ ___ ___  \n// | o |   | x |\n//  ___ ___ ___  \n// |   |   |   |\n//  ___ ___ ___  \n// |   |   |   |\n//  ___ ___ ___  \n//\n//  Round: 1\n```\n\n\n### 7. \u003ca name=\"class.getWinner\"\u003e\u003c/a\u003e Get the winner [ class.getWinner() ]\n\nWhen the bot stopped running, means that finish all the process and you can call `class.getWinner()` and will return 4 values `false | 'bot' | 'user' | 'draw'`\n\n- `false`: When nobody won or the round is in process or not finished\n- `'bot'`: When the bot won the game\n- `'user'`: When the user won the game\n- `'draw'`: When the process finished and nobody won the game\n\n```javascript\nconsole.log(TKAPI.getWinner());\n\n//Output: Str | Boolean\n//\n// false\n```\n\n\n### 8. \u003ca name=\"class.reset\"\u003e\u003c/a\u003e Reset all [ class.reset() ]\n\nFor reset all\n\n\n\n## \u003ca name=\"examples\"\u003e\u003c/a\u003e Examples\n\nHTML\n```html\n\u003csection class=\"tkGUI-viewer\"\u003e\n    \u003cdiv class=\"0\" block-position=\"0\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"1\" block-position=\"1\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"2\" block-position=\"2\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"3\" block-position=\"3\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"4\" block-position=\"4\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"5\" block-position=\"5\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"6\" block-position=\"6\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"7\" block-position=\"7\"\u003e\u003c/div\u003e\n    \u003cdiv class=\"8\" block-position=\"8\"\u003e\u003c/div\u003e\n\u003c/section\u003e\n```\n\n\nJavaScript\n```javascript\nconst TKAPI = new TkApi(); // DEFAULTS OPTIONS\n\n// console.log(TKAPI.options);  IF YOU WANT TO SEE THE CURRENT OPTIONS AND CHANGE IT IF YOU WANT, IT IS A PUBLIC PROPERTY\nlet gameMarker = TKAPI.options.symbol;\n\nlet btnPositionDiv = document.querySelectorAll('.tkGUI-viewer \u003e div');\nbtnPositionDiv.forEach(el =\u003e{\n    el.addEventListener('click', ()=\u003e{\n        let botNum = TKAPI.getResponse(parseInt(el.getAttribute('block-position')));\n        // IF BOT RETURN FALSE DO NOT DO ANYTHING\n        // REMMENBER THAT EXIST THE POSITION 0, SO YOU NEED TO BE CAREFULL TO USE if(botNum){} BECAUSE THAT WILL RETURN FALSE WHEN THE BOT RETURN POSITION 0\n        if(botNum !== false){ \n            // IF THE BOT RETURN A NUMBER MEANS THAT ALL IS GOING WELL AND YOU CAN CONTINUE RUNNING THE PROCESS HERE\n            el.innerHTML = gameMarker.user;\n\n            // REMMENBER THAT EXIST THE -1 STATUS AND MEANS THAT THE BOT STOPPED WORKING BECAUSE SOMEONE WON, AND IS WAITING THE USER FOR RESET\n            if(botNum \u003e= 0){\n                btnPositionDiv[botNum].innerHTML = gameMarker.bot;\n            }\n\n            // CHECK THE GAME STATUS WITH class.getWinner();\n\n            // FOR SIMPLY UI VIEW IN DEBUG PROCCESS YOU CAN USE THE class.getSimplyUI();\n\n            let statusGame = TKAPI.getWinner();\n\n            if(statusGame){\n                // CONSOLE THE STATUS\n\n                console.log(statusGame);\n            }\n        }\n    });\n});\n```\n\n\n## \u003ca name=\"extension\"\u003e\u003c/a\u003e Extension\n\nWith the main file js you can create your own tik tak toe game code, but if you want to make the game fastly you can use the default GUI extensions\n\n\n\n### 1. Include this script after the main script\n\n```html\n\u003cscript src=\"./min/tkapiGui.min.js\"\u003e\u003c/script\u003e\n```\n\n\n### 2. Create the variable\n```javascript\nlet element = document.getElementById('element'); // The element where the library are going to insert the code\nlet options = {}; // The options of TkApi\nconst TKAPIGUI = new TkApiGui(element, options, (statusGame) =\u003e { // Do this when someone won the game });\n```\n\n### 3. Examples of code\n```javascript\nlet element = document.getElementById('element');\nlet options = {};\nconst TKAPIGUI = new TkApiGui(element, options, (statusGame) =\u003e {\n  // PRINT THE STATUS\n  console.log(statusGame);\n});\n```\n\n\n\n\n\n\n### Love this repo? Give us a star ⭐\n\n\u003ca href=\"./\"\u003e\n  \u003cimg src=\"https://img.shields.io/badge/TkAPI-Rate-blue\"\u003e\n\u003c/a\u003e","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhenglinlei%2Ftkapi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhenglinlei%2Ftkapi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhenglinlei%2Ftkapi/lists"}