{"id":23875111,"url":"https://github.com/gonzyui/dofus-api-wrapper","last_synced_at":"2026-02-10T07:32:49.578Z","repository":{"id":268168963,"uuid":"903527580","full_name":"gonzyui/Dofus-API-Wrapper","owner":"gonzyui","description":"A powerful Node.js module to interact with the Dofus API in TypeScript.","archived":false,"fork":false,"pushed_at":"2024-12-14T21:25:49.000Z","size":15,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-03T18:16:31.050Z","etag":null,"topics":["api","api-wrapper","dofus"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/gonzyui.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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":"2024-12-14T20:37:14.000Z","updated_at":"2024-12-26T19:53:48.000Z","dependencies_parsed_at":"2024-12-14T21:28:43.557Z","dependency_job_id":"bf8399a4-d807-4ffb-b0b5-d357c7d22fe0","html_url":"https://github.com/gonzyui/Dofus-API-Wrapper","commit_stats":null,"previous_names":["gonzyui/dofus-api-wrapper"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzyui%2FDofus-API-Wrapper","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzyui%2FDofus-API-Wrapper/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzyui%2FDofus-API-Wrapper/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/gonzyui%2FDofus-API-Wrapper/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/gonzyui","download_url":"https://codeload.github.com/gonzyui/Dofus-API-Wrapper/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240236230,"owners_count":19769573,"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","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":["api","api-wrapper","dofus"],"created_at":"2025-01-03T18:16:32.662Z","updated_at":"2025-02-22T20:46:17.969Z","avatar_url":"https://github.com/gonzyui.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Dofus API Wrapper\r\n\r\nA powerful Node.js module to interact with the [Dofus](https://dofus.com) API in TypeScript. It provides methods to fetch data like items, monsters, sets, and spells from the Dofus database, with robust error handling and logging.\r\n\r\n## Features\r\n\r\n- Fetch data about items, monsters, sets, and spells.\r\n- Support for multiple languages (e.g., English, French).\r\n- Robust error handling with detailed logging.\r\n- Extendable design for integration with other applications like Discord bots.\r\n- TypeScript support for better type safety and maintainability.\r\n---\r\n## Installation\r\n\r\nTo install the module, use `npm`.\r\n\r\n```bash\r\nnpm install dofus-api-wrapper\r\n```\r\n---\r\n## Configuration\r\n\r\nCreate a `.env` file to configure the base URL of the API.\r\n\r\n```bash\r\nAPI_BASE_URL=https://api.dofusdb.fr\r\n```\r\n---\r\n\r\n## Usage\r\n#### Setup\r\nTo start using the wrapper, import the `DofusService` class and instantiate it:\r\n\r\n```ts\r\nimport { DofusService } from 'dofus-api-wrapper';\r\n\r\nconst dofusService = new DofusService(); // Defaults to the API_BASE_URL from the .env file\r\n```\r\n#### Fetching items\r\n\r\n```ts\r\nconst items = await dofusService.fetchItems('en'); // Fetches items in English\r\nconsole.log(items.slice(0, 5)); // Prints the first 5 items\r\n```\r\n#### Fetching monsters\r\n\r\n```ts\r\nconst monsters = await dofusService.fetchMonsters('fr'); // Fetches monsters in French\r\nconsole.log(monsters.slice(0, 5)); // Prints the first 5 monsters\r\n```\r\n\r\n#### Fetching sets\r\n\r\n```ts\r\nconst sets = await dofusService.fetchSets('en'); // Fetches sets in English\r\nconsole.log(sets.slice(0, 5)); // Prints the first 5 sets\r\n```\r\n\r\n#### Fetching spells\r\n\r\n```ts\r\nconst spells = await dofusService.fetchSpells('fr'); // Fetches spells in French\r\nconsole.log(spells.slice(0, 5)); // Prints the first 5 spells\r\n```\r\n\r\nJavascript integration\r\n```js\r\nconst { DofusService } = require('dofus-api-wrapper');\r\n\r\nconst dofusService = new DofusService();\r\n\r\nasync function main() {\r\n  try {\r\n    console.log('Fetching items...');\r\n    const items = await dofusService.fetchItems('fr');\r\n    console.log('First 5 items:', items.slice(0, 5));\r\n\r\n    console.log('\\nFetching monsters...');\r\n    const monsters = await dofusService.fetchMonsters('fr');\r\n    console.log('First 5 monsters:', monsters.slice(0, 5));\r\n\r\n    console.log('\\nFetching sets...');\r\n    const sets = await dofusService.fetchSets('fr');\r\n    console.log('First 5 sets:', sets.slice(0, 5));\r\n\r\n    console.log('\\nFetching spells...');\r\n    const spells = await dofusService.fetchSpells('fr');\r\n    console.log('First 5 spells:', spells.slice(0, 5));\r\n  } catch (error) {\r\n    console.error('An error occurred:', error);\r\n  }\r\n}\r\n\r\nmain();\r\n```\r\n\r\n#### Error logging\r\n\r\nIn case of errors, detailed logs will be saved to a file named `dofusdb.log` in the logs directory. You can inspect this file for debugging purposes.\r\n\r\n---\r\n\r\n## Discord Bot Integration\r\n\r\nThe wrapper can be easily integrated into a Discord bot. Below is a sample implementation using [discord.js](https://discord.js.org/).\r\n\r\n#### Bot Setup\r\n\r\nInstall the necessary packages:\r\n```bash\r\nnpm install discord.js dotenv dofusdb-ts-wrapper\r\n```\r\n\r\nCreate a .env file for your Discord bot token and the Dofus API base URL:\r\n```dotenv\r\nDISCORD_TOKEN=your-discord-bot-token\r\nAPI_BASE_URL=https://api.dofusdb.fr\r\n```\r\n\r\nImplement the bot\r\n```ts\r\nimport { Client, GatewayIntentBits } from 'discord.js';\r\nimport { DofusService } from 'dofus-api-wrapper';\r\nimport dotenv from 'dotenv';\r\n\r\ndotenv.config();\r\n\r\nconst dofusService = new DofusService();\r\nconst client = new Client({\r\n  intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent],\r\n});\r\n\r\nclient.on('ready', () =\u003e {\r\n  console.log(`Bot logged in as ${client.user?.tag}`);\r\n});\r\n\r\nclient.on('messageCreate', async (message) =\u003e {\r\n  if (message.author.bot) return;\r\n\r\n  if (message.content.startsWith('!items')) {\r\n    const items = await dofusService.fetchItems('en');\r\n    if (items.length \u003e 0) {\r\n      const itemNames = items.slice(0, 5).map((item) =\u003e item.name?.en || 'Unknown').join('\\n');\r\n      message.channel.send(`Here are the first 5 items:\\n${itemNames}`);\r\n    } else {\r\n      message.channel.send('Could not fetch items. Please try again later.');\r\n    }\r\n  }\r\n\r\n  if (message.content.startsWith('!monsters')) {\r\n    const monsters = await dofusService.fetchMonsters('en');\r\n    if (monsters.length \u003e 0) {\r\n      const monsterNames = monsters.slice(0, 5).map((monster) =\u003e monster.name?.en || 'Unknown').join('\\n');\r\n      message.channel.send(`Here are the first 5 monsters:\\n${monsterNames}`);\r\n    } else {\r\n      message.channel.send('Could not fetch monsters. Please try again later.');\r\n    }\r\n  }\r\n\r\n  if (message.content.startsWith('!sets')) {\r\n    const sets = await dofusService.fetchSets('en');\r\n    if (sets.length \u003e 0) {\r\n      const setNames = sets.slice(0, 5).map((set) =\u003e set.name?.en || 'Unknown').join('\\n');\r\n      message.channel.send(`Here are the first 5 sets:\\n${setNames}`);\r\n    } else {\r\n      message.channel.send('Could not fetch sets. Please try again later.');\r\n    }\r\n  }\r\n\r\n  if (message.content.startsWith('!spells')) {\r\n    const spells = await dofusService.fetchSpells('en');\r\n    if (spells.length \u003e 0) {\r\n      const spellNames = spells.slice(0, 5).map((spell) =\u003e spell.name?.en || 'Unknown').join('\\n');\r\n      message.channel.send(`Here are the first 5 spells:\\n${spellNames}`);\r\n    } else {\r\n      message.channel.send('Could not fetch spells. Please try again later.');\r\n    }\r\n  }\r\n});\r\n\r\nclient.login(process.env.DISCORD_TOKEN);\r\n```\r\n\r\nCompile and run the bot\r\n```bash\r\ntsc\r\nnode dist/bot.js\r\n```\r\n\r\n## Roadmap\r\n\r\n- Roadmap\r\n- Add search functionality for specific items, monsters, sets, or spells.\r\n- Improve logging with configurable log levels (INFO, WARN, ERROR).\r\n- Extend Discord bot commands to allow dynamic queries (e.g., !item \u003cname\u003e).\r\n- Add unit and integration tests for robustness.\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzyui%2Fdofus-api-wrapper","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgonzyui%2Fdofus-api-wrapper","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgonzyui%2Fdofus-api-wrapper/lists"}