Closed DQ318 closed 2 years ago
Download Node here: https://nodejs.org/en/.
Note that this library uses the experimental Node fetch() API so you will have to get the Node version marked Current
and not LTS
.
Once you install Node, you can run npm init
from the command line to create a new npm project.
Then you can install this API for use in your project with npm install fightcade-api
.
I suggest using TypeScript, but you can use JavaScript if you want.
Install the TypeScript compiler globally using npm install -g typescript
. This will give you access to the TypeScript compiler command tsc
in the command line.
You can create a source code file named index.ts
and copy one of the examples on this repo's home page.
Transpile your TypeScript into JavaScript from the command line with tsc index.ts
.
Run your program from the command line with node index.js
.
Hi, @xBiggs! How are you? Can run your API. Pretty cool ;) I have another question: is it possible to get the results of a ranked game for a given user? For example, xBiggs beat FT 5 x 0, can I get these values?
@DQ318 Here is a code sample
import * as Fightcade from 'fightcade-api';
const main = async () => {
try {
// Match ID
const quarkid = '1664758449709-7461';
// Query Match Information
const replay = await Fightcade.GetReplay(quarkid);
// The ranked property denotes the FT set. 0 is unrannked
if (replay.ranked === 0) console.log(`Unranked Match: ${quarkid}`);
else {
console.log(`Ranked FT${replay.ranked} ${quarkid} Results:`);
// The score property denotes the set results
replay.players.forEach(player => console.log(`${player.name} - ${player.score}`));
}
} catch (e) {
console.error((e as Error).message);
}
}
main();
The output was:
Ranked FT3 1664758449709-7461 Results:
tehdrewsus - 1
biggs - 3
Man, your work is very interesting! I would like to know how I can test your api. I don't know much about TypeScript or Javascript so I couldn't print the json on the screen. I would really appreciate it if you could help me with this. Thanks