Skip to content

Commit 1b79583

Browse files
author
Kimon Kar
authored
Update README.md
1 parent 5181c7e commit 1b79583

File tree

1 file changed

+78
-2
lines changed

1 file changed

+78
-2
lines changed

README.md

Lines changed: 78 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,81 @@
11
# xivapi-js
22

3-
Welcome! This is a pure JS wrapper for interacting with [XIVAPI](https://xivapi.com/) and handling all requests in a simple, promise-driven manner.
3+
This is a pure JS wrapper for interacting with [XIVAPI](https://xivapi.com/) and handling all requests in a simple, promise-driven manner.
44

5-
Check out the [wiki](https://github.com/TheSacredPixel/xivapi-js/wiki) for usage help!
5+
## Installation
6+
7+
Simply add the module to your node project with `npm`:
8+
```
9+
npm i xivapi-js
10+
```
11+
12+
## Usage
13+
14+
Require and initialize the module in your code:
15+
```js
16+
const XIVAPI = require('xivapi-js')
17+
const xiv = new XIVAPI('yourAPIkey')
18+
```
19+
20+
...and then check out the [wiki](https://github.com/xivapi/xivapi-js/wiki) for usage help!
21+
22+
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 @SacredPixel#0039.
23+
24+
### Examples:
25+
26+
Find an item ID, and then get the lowest market board price in a specific server:
27+
```js
28+
const getItemPrice = async () => {
29+
//find item
30+
let res = await xiv.search('Stuffed Khloe')
31+
32+
//use item ID for market query
33+
res = await xiv.market.prices(res.Results[0].ID, 'Excalibur')
34+
35+
//return lowest price
36+
return res.Prices[0].PricePerUnit
37+
}
38+
```
39+
40+
Get the most recent lodestone news post:
41+
```javascript
42+
const getLatestNews = async () => {
43+
//get the lodestone state
44+
let ls = await xiv.lodestone()
45+
46+
//get most recent entry
47+
let entry = ls.News[0]
48+
49+
//get the time since the entry's creation
50+
let timeNow = new Date()
51+
let diff = new Date(timeNow - entry.Time) //xivapi-js converts the timestamp into a Date object,
52+
//so you can just do this!
53+
54+
//return your parsed entry
55+
console.log(`${entry.Title} (published ${diff.getUTCMinutes()} minutes ago)`)
56+
}
57+
```
58+
59+
Check for character ownership using a token we generated and provided to the user:
60+
```js
61+
const verifyCharacter = async () => {
62+
//find the character with their name and server
63+
let res = await xiv.character.search('Kai Megumi', {server: 'excalibur'}) //case insensitive server names, btw ;)
64+
65+
//get the character's ID
66+
let id = res.Results[0].ID
67+
68+
//return whether or not the character's lodestone bio matches our token
69+
return await xiv.character.verification(id, 'token string')
70+
}
71+
```
72+
73+
## Contribute
74+
75+
Feel free to open up issues/PRs or anything else.
76+
77+
Just `git clone https://github.com/xivapi/xivapi-js.git`, run `npm i`, and go to town!
78+
79+
## License
80+
81+
This project is open source, under the terms described in the [MIT License](LICENSE).

0 commit comments

Comments
 (0)