Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions .eslintrc.json

This file was deleted.

12 changes: 11 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
/node_modules
# ignore build outputs
dist/
coverage/
build/

# ignore dependencies
node_modules/

# ignore package locks and logs
yarn.lock
*.log
120 changes: 76 additions & 44 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,75 +3,107 @@
[![npm version](https://badge.fury.io/js/%40xivapi%2Fjs.svg)](https://badge.fury.io/js/%40xivapi%2Fjs)
[![license](https://img.shields.io/github/license/xivapi/xivapi-js.svg)](LICENSE)

This is a pure JS wrapper for interacting with [XIVAPI](https://xivapi.com/) and handling all requests in a simple, promise-driven manner.
A JavaScript library for working with [XIVAPI v2](https://v2.xivapi.com/), providing a source of Final Fantasy XIV game data. It lets you fetch, search, and use FFXIV data easily in a promise-based manner.

> [!WARNING]
> `@xivapi/js@0.4.5` (using XIVAPI v1) is now deprecated. Please use it at your own risk. We strongly recommend you update to the latest version. Migration guide and details: https://v2.xivapi.com/docs/migrate/.

If you need help or run into any issues, please [open an issue](https://github.com/xivapi/xivapi-js/issues) on GitHub or join the [XIVAPI Discord server](https://discord.gg/MFFVHWC) for support.

## Installation

Simply add the module to your node project with `npm`:
```
npm i @xivapi/js
```bash
npm install @xivapi/js@latest # or use yarn, pnpm, or bun
```

## Usage
## Usage Examples

#### 1. Importing and Initialization

Require and initialize the module in your code:
```js
const XIVAPI = require('@xivapi/js')
const xiv = new XIVAPI()
```
import xivapi from '@xivapi/js';

...and then check out the [wiki](https://github.com/xivapi/xivapi-js/wiki) for usage help!
// Basic instance
const xiv = new xivapi();

If you get really stuck and need some help, or run into any problems/concerns, either open up an issue on github or join the [XIVAPI discord server](https://discord.gg/MFFVHWC) and ping/DM @kaimoe.
// With options
const xivCustom = new xivapi({
version: "7.0", // specify game version
language: "jp", // specify language (jp, en, de, fr)
verbose: true // output more logging
});
```

### Examples:
#### 2. Get an Item

Find an item's ID:
```js
const getID = async () => {
//find item
let res = await xiv.search('Stuffed Khloe')
// Fetch the Gil item (item ID 1)
const item = await xiv.items.get(1);

//return item ID
return res.Results[0].ID
}
console.log(item.Name); // "Gil" (or equivalent in your language)
```

Search for an FC and get an list of members:
```javascript
const getMembers = async () => {
//find the FC with its name and server
let res = await xiv.freecompany.search('My Fun FC', {server: 'Excalibur'})
#### 3. Search Example

//get the FC ID
let id = res.Results[0].ID

//get and return fc members
let fc = await xiv.freecompany.get('9231253336202687179', {data: FCM})
return fc.FreeCompanyMembers
```js
// Find all items named "gil"
const params = {
query: 'Name~"gil"',
sheets: "Item"
};

const { results } = await xiv.search(params);
console.log(results[0]);

/*
Output example:
{
"score": 1,
"sheet": "Item",
"row_id": 1,
"fields": {
"Icon": {
"id": 65002,
"path": "ui/icon/065000/065002.tex",
"path_hr1": "ui/icon/065000/065002_hr1.tex"
},
"Name": "Gil",
"Singular": "gil"
}
}
*/
```

Check for character ownership using a token we generated and provided to the user:
#### 4. Using Raw XIVAPI v2 Endpoints

```js
const verifyCharacter = async () => {
//find the character with their name and server
let res = await xiv.character.search('Kai Megumi', {server: 'excalibur'}) //case insensitive server names, btw ;)
// Fetch a raw asset file (e.g. icon image)
const asset = await xiv.data.assets.get({
path: "ui/icon/051000/051474_hr1.tex",
format: "png" // jpg or webp also supported
});

// List all quests
const quests = await xiv.data.sheets.list("Quest");
console.log(quests);

// List available game versions
const versions = await xiv.data.versions();
console.log(versions[0]); // e.g. "7.0"
```

//get the character
let char = res.Results[0]
## Contributing

//return whether or not the character's lodestone bio matches our token
return char.Bio === 'example_token'
}
```
We welcome all contributions! Whether you'd like to report a bug, suggest a feature, improve the documentation, or submit a pull request, your help is appreciated.

## Contribute
To get started, clone the repository with: `git clone https://github.com/xivapi/xivapi-js.git`

Feel free to open up issues/PRs or anything else.
Before opening a pull request, please:
- Make sure your code passes linting and all current tests (`npm run lint && npm test`).
- Clearly explain your changes and reference any relevant issues in your PR description.

Just `git clone https://github.com/xivapi/xivapi-js.git`, run `npm i`, and go to town!
If you have questions, suggestions, or want to discuss changes before contributing, feel free to open an issue!

## License

This project is open source, under the terms described in the [MIT License](LICENSE).
MIT License - see [LICENSE](LICENSE) file for details.
58 changes: 0 additions & 58 deletions XIVAPI.js

This file was deleted.

27 changes: 27 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import js from "@eslint/js"
import globals from "globals"
import tseslint from "typescript-eslint"
import { defineConfig, globalIgnores } from "eslint/config"

export default defineConfig([
{
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
plugins: { js },
extends: ["js/recommended"],
languageOptions: { globals: globals.node },
},
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
globalIgnores(["tests/**/*.test.ts", "dist/**/*.js"]),
tseslint.configs.recommended,
{
rules: {
"@typescript-eslint/no-namespace": "off",
"consistent-return": 2,
"no-console": 0,
quotes: [2, "double"],
semi: [2, "never"],
"linebreak-style": [2, "unix"],
indent: [2, "tab", { SwitchCase: 1 }],
},
},
])
14 changes: 0 additions & 14 deletions lib/Lib.js

This file was deleted.

35 changes: 0 additions & 35 deletions lib/character.js

This file was deleted.

28 changes: 0 additions & 28 deletions lib/cwl.js

This file was deleted.

Loading