Skip to content

Commit f7359c2

Browse files
authored
Merge pull request #19 from c0reme/v2-upgrade
feat: upgrade to v2
2 parents 890946e + 8951d1b commit f7359c2

36 files changed

+4996
-1357
lines changed

.eslintrc.json

Lines changed: 0 additions & 33 deletions
This file was deleted.

.gitignore

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,11 @@
1-
/node_modules
1+
# ignore build outputs
2+
dist/
3+
coverage/
4+
build/
5+
6+
# ignore dependencies
7+
node_modules/
8+
9+
# ignore package locks and logs
10+
yarn.lock
11+
*.log

README.md

Lines changed: 76 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -3,75 +3,107 @@
33
[![npm version](https://badge.fury.io/js/%40xivapi%2Fjs.svg)](https://badge.fury.io/js/%40xivapi%2Fjs)
44
[![license](https://img.shields.io/github/license/xivapi/xivapi-js.svg)](LICENSE)
55

6-
This is a pure JS wrapper for interacting with [XIVAPI](https://xivapi.com/) and handling all requests in a simple, promise-driven manner.
6+
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.
7+
8+
> [!WARNING]
9+
> `@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/.
10+
11+
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.
712

813
## Installation
914

10-
Simply add the module to your node project with `npm`:
11-
```
12-
npm i @xivapi/js
15+
```bash
16+
npm install @xivapi/js@latest # or use yarn, pnpm, or bun
1317
```
1418

15-
## Usage
19+
## Usage Examples
20+
21+
#### 1. Importing and Initialization
1622

17-
Require and initialize the module in your code:
1823
```js
19-
const XIVAPI = require('@xivapi/js')
20-
const xiv = new XIVAPI()
21-
```
24+
import xivapi from '@xivapi/js';
2225

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

25-
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.
29+
// With options
30+
const xivCustom = new xivapi({
31+
version: "7.0", // specify game version
32+
language: "jp", // specify language (jp, en, de, fr)
33+
verbose: true // output more logging
34+
});
35+
```
2636

27-
### Examples:
37+
#### 2. Get an Item
2838

29-
Find an item's ID:
3039
```js
31-
const getID = async () => {
32-
//find item
33-
let res = await xiv.search('Stuffed Khloe')
40+
// Fetch the Gil item (item ID 1)
41+
const item = await xiv.items.get(1);
3442

35-
//return item ID
36-
return res.Results[0].ID
37-
}
43+
console.log(item.Name); // "Gil" (or equivalent in your language)
3844
```
3945

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

46-
//get the FC ID
47-
let id = res.Results[0].ID
48-
49-
//get and return fc members
50-
let fc = await xiv.freecompany.get('9231253336202687179', {data: FCM})
51-
return fc.FreeCompanyMembers
48+
```js
49+
// Find all items named "gil"
50+
const params = {
51+
query: 'Name~"gil"',
52+
sheets: "Item"
53+
};
54+
55+
const { results } = await xiv.search(params);
56+
console.log(results[0]);
57+
58+
/*
59+
Output example:
60+
{
61+
"score": 1,
62+
"sheet": "Item",
63+
"row_id": 1,
64+
"fields": {
65+
"Icon": {
66+
"id": 65002,
67+
"path": "ui/icon/065000/065002.tex",
68+
"path_hr1": "ui/icon/065000/065002_hr1.tex"
69+
},
70+
"Name": "Gil",
71+
"Singular": "gil"
72+
}
5273
}
74+
*/
5375
```
5476

55-
Check for character ownership using a token we generated and provided to the user:
77+
#### 4. Using Raw XIVAPI v2 Endpoints
78+
5679
```js
57-
const verifyCharacter = async () => {
58-
//find the character with their name and server
59-
let res = await xiv.character.search('Kai Megumi', {server: 'excalibur'}) //case insensitive server names, btw ;)
80+
// Fetch a raw asset file (e.g. icon image)
81+
const asset = await xiv.data.assets.get({
82+
path: "ui/icon/051000/051474_hr1.tex",
83+
format: "png" // jpg or webp also supported
84+
});
85+
86+
// List all quests
87+
const quests = await xiv.data.sheets.list("Quest");
88+
console.log(quests);
89+
90+
// List available game versions
91+
const versions = await xiv.data.versions();
92+
console.log(versions[0]); // e.g. "7.0"
93+
```
6094

61-
//get the character
62-
let char = res.Results[0]
95+
## Contributing
6396

64-
//return whether or not the character's lodestone bio matches our token
65-
return char.Bio === 'example_token'
66-
}
67-
```
97+
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.
6898

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

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

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

75107
## License
76108

77-
This project is open source, under the terms described in the [MIT License](LICENSE).
109+
MIT License - see [LICENSE](LICENSE) file for details.

XIVAPI.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

eslint.config.js

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import js from "@eslint/js"
2+
import globals from "globals"
3+
import tseslint from "typescript-eslint"
4+
import { defineConfig, globalIgnores } from "eslint/config"
5+
6+
export default defineConfig([
7+
{
8+
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
9+
plugins: { js },
10+
extends: ["js/recommended"],
11+
languageOptions: { globals: globals.node },
12+
},
13+
{ files: ["**/*.js"], languageOptions: { sourceType: "commonjs" } },
14+
globalIgnores(["tests/**/*.test.ts", "dist/**/*.js"]),
15+
tseslint.configs.recommended,
16+
{
17+
rules: {
18+
"@typescript-eslint/no-namespace": "off",
19+
"consistent-return": 2,
20+
"no-console": 0,
21+
quotes: [2, "double"],
22+
semi: [2, "never"],
23+
"linebreak-style": [2, "unix"],
24+
indent: [2, "tab", { SwitchCase: 1 }],
25+
},
26+
},
27+
])

lib/Lib.js

Lines changed: 0 additions & 14 deletions
This file was deleted.

lib/character.js

Lines changed: 0 additions & 35 deletions
This file was deleted.

lib/cwl.js

Lines changed: 0 additions & 28 deletions
This file was deleted.

0 commit comments

Comments
 (0)