For project guidelines please see https://github.com/TrickingApi/trickingapi
Contents
Install
npm
npm install @trickingapi/tricking-ts --save
or yarn
yarn add @trickingapi/tricking-ts
If you wish to include the raw tricks data directly in your project also import tricks-core-data
npm install @trickingapi/tricks-core-data --save
or
yarn add @trickingapi/tricks-core-data
Usage To start using tricking-ts:
Import one of the clients into your project:
import { TricksClient, CategoriesClient } from '@trickingapi/tricking-ts';
TricksClient
Used to access the /tricks/*
endpoints from a running instance of TrickingAPI
Create an instance of the TricksClient class, leave the constructor blank if you wish to use the public instance of TrickingAPI
const client = new TricksClient();
If you're running the api on your own machine or your own version of the server pass the baseURL as so:
const client = new TricksClient({
baseURL: 'localhost:8080'
});
The client also accepts a logOptions
parameter of type pino.LoggerOptions
, see https://getpino.io/#/docs/api?id=options for more.
Implemented APIS
- /tricks (https://trickingapi.dev/api/tricks)
const tricks: Trick[] = await client.getAllTrick();
Returns
{
"360CartwheelTwist": {
"id": "360CartwheelTwist",
"name": "360 Cartwheel Twist",
"aliases": [],
"categories": [
"FORWARD"
],
"prereqs": [
"360 Cartwheel"
],
"nextTricks": [],
"description": "A 360 Cartwheel with another twist executed before landing."
},
"540": {
"id": "540",
"name": "540",
"aliases": [
"Cheat 360 Katana (TKT)"
],
"categories": [
"VERT_KICK"
],
"prereqs": [
"Tornado"
],
"nextTricks": [
"Jackknife",
"Backside 900 Hyper",
"540 Gyro",
"Sideswipe"
],
"description": "A Tornado that lands in hyper (extra 180°) on the inside kicking leg."
},
"540Gyro": {
"id": "540Gyro",
"name": "540 Gyro",
"aliases": [
"Cheat 360 Katana Gyro (TKT)"
],
"categories": [
"VERT_KICK"
],
"prereqs": [
"540"
],
"nextTricks": [
"Backside 900 Gyro",
"540 Gyroknife",
"Cheat 900 Gyro"
],
"description": "A 540 with an extra twist, landing back in Complete stance."
},
"540Gyroknife": {
"id": "540Gyroknife",
"name": "540 Gyroknife",
"aliases": [
"Cheat 360 Katana Gyroknife (TKT)"
],
"categories": [
"VERT_KICK"
],
"prereqs": [
"540 Gyro"
],
"nextTricks": [],
"description": "A 540 Gyro that finishes with a hyperhook. Could be thought of as a vertical Snapu Hyperhook."
},
.
.
.
- /tricks/names (https://trickingapi.dev/api/tricks/names)
const tricksNames: <Map<string,string>> = await client.getAllTrickNames();
Returns
{
"360CartwheelTwist": "360 Cartwheel Twist",
"540": "540",
"540Gyro": "540 Gyro",
"540Gyroknife": "540 Gyroknife",
"aerial": "Aerial",
"aerialHelicoptero": "Aerial Helicoptero",
"aerialHook": "Aerial Hook",
"aerialMega": "Aerial Mega",
"aerialScissor": "Aerial Scissor",
"aerialSidewinder": "Aerial Sidewinder",
"aerialTwist": "Aerial Twist",
"aerialTwistDoubleleg": "Aerial Twist Doubleleg",
}
- /tricks/:name (https://trickingapi.dev/api/tricks/:name)
const butterflyTwist: Trick = await client.getTrickByName('butterflyTwist');
Returns
{
"id": "butterflyTwist",
"name": "Butterfly Twist",
"aliases": [
"B-Twist",
"Barrel Roll"
],
"categories": [
"TWIST",
"SINGLE",
"INSIDE"
],
"prereqs": [
"Butterfly Kick"
],
"nextTricks": [
"Aerial Twist",
"Butterfly Twist Round",
"Butterfly Twist Doubleleg",
"Sidewinder",
"Butterfly Twist Axe",
"Touchdown Butterfly Twist",
"Cheat 720 Twist",
"Spyder Twist",
"Butterfly Twist-In",
"Butterfly Twist Hyper",
"Butterfly Twist Shuriken",
"Janitor Twist"
],
"description": "A Butterfly Kick with an extra 360° rotation done in the air before landing on the horizontal axis."
}
Categories Client
Used to access /categories/*
endpoints from a running instance of TrickingAPI
Create an instance of the CategoriesClient class, leave the constructor blank if you wish to use the public instance of TrickingAPI
const client = new CategoriesClient();
Categories endpoints:
- /categories (https://trickingapi.dev/api/categories)
const categories: TrickCategory[[] = await client.getAllCategories();
Returns
[
"FLIP",
"VERT_KICK",
"TWIST",
"PSEUDO_DOUBLE_FLIP",
"SINGLE",
"DOUBLE",
"TRIPLE",
"QUAD",
"GROUNDWORK",
"UNKNOWN",
"VARIATION",
"INSIDE",
"OUTSIDE",
"FORWARD",
"BACKWARD"
]
- /categories/tricks (https://trickingapi.dev/api/categories/tricks)
const categoriesToTricksMap: Map<TrickCategory, Trick[]> = await client.getAllTrickByCategory();
Returns
{
"BACKWARD": [
{
"id": "corkscrewWackknife",
"name": "Corkscrew Wackknife",
"aliases": [],
"categories": [
"BACKWARD"
],
"prereqs": [
"Corkscrew",
"Wackknife"
],
"nextTricks": [
"Double Corkscrew Wackknife"
],
"description": "A Corkscrew that finishes with a Wackknife."
},
{
"id": "doubleGainer",
"name": "Double Gainer",
"aliases": [],
"categories": [
"BACKWARD"
],
"prereqs": [
"Gainer Tuck"
],
"nextTricks": [],
"description": "A Gainer Tuck with two flips. First landed by Vellu in February, 2011."
},
...,
"VERT_KICK": [...],
"TWIST": [...],
...
}
- /categories/:name (https://trickingapi.dev/api/categories/:name)
const vertKicks: Trick[] = await client.getTricksForCategory('VERT_KICK');
Returns
[
{
"id": "cheat720Shuriken",
"name": "Cheat 720 Shuriken",
"aliases": [
"Cheat 540 Shuriken (TKT)",
" Cheat 720 \"Hyper\""
],
"categories": [
"VERT_KICK"
],
"prereqs": [
"Pop 360 Shuriken"
],
"nextTricks": [
"Cheat 1080 Shuriken"
],
"description": "A Cheat 720 that lands on the kicking leg in true hyper (TKT) / mega stance."
},
{
"id": "crowdAwakener",
"name": "Crowd Awakener",
"aliases": [
"Cheat 360 Crowd Awakener (TKT)"
],
"categories": [
"VERT_KICK",
"VARIATION"
],
"prereqs": [
"Tornado"
],
"nextTricks": [
"Crowd Awakener Knife",
"Cheat 900 Crowd Awakener"
],
"description": "A Tornado with a split kick / straddle."
},
...
]
Core-Data If you want to direct access to the underlying data used in [TrickingAPI](https://github.com/TrickingApi/trickingapi) you can directly add [tricks-core-data](https://github.com/TrickingApi/tricks-core-data) to your project. ``` npm install --save-dev @trickingapi/tricks-core-data ```
or
yarn add @trickingapi/tricks-core-data
Usage
import * as Tricks from '@trickingapi/tricks-core-data/tricks';
// Do something with each trick
Object.entries(Tricks).map(([, trick]) => {
someProcessingFunction(trick);
}
Types Tricking-Ts exports the following data types
Trick
export interface Trick {
readonly id: string;
readonly name: string;
readonly aliases: string;
readonly categories: TrickCategory[];
readonly prereqs: Array<string>;
readonly nextTricks: Array<string>;
readonly description: string;
}
TrickCategory
export declare enum TrickCategory {
FLIP = "FLIP",
VERT_KICK = "VERT_KICK",
TWIST = "TWIST",
PSEUDO_DUB = "PSEUDO_DOUBLE_FLIP",
SING = "SINGLE",
DUB = "DOUBLE",
TRIP = "TRIPLE",
QUAD = "QUAD"
}
TrickError
Standard error object that TrickingAPI
export interface TrickError {
readonly data: string;
readonly message: string;
readonly success: boolean;
}
Contributing Interested in contributing? Great! All contributions are welcome: bug fixes, data contributions, recommendations.
Please see the issues on GitHub before you submit a pull request or raise an issue, someone else might have beat you to it.
To contribute to this repository:
-
Download the forked project using git clone:
git clone git@github.com:<YOUR_USERNAME>/tricking-ts.git
-
Create a new branch with a descriptive name:
git checkout -b my_new_branch
-
New Feature/Bugfix?
- Write some code, fix something, and add a test to prove that it works. *No pull request will be accepted without existing tests passing, or without new tests if new features are added.
Want to update the core-data? See TrickingAPI contributing guidelines.
-
Create an issue under the "new trick" label, fill out the template, and assign it to yourself (if you intend to make the change yourself). Please use the [Corkscrew Request Issue](https://github.com/TrickingApi/trickingapi/issues/5 as an example!
-
Commit your code and push it to GitHub
-
Open a new pull request and describe the changes you have made.
-
We'll accept your changes after review.
Simple!
Questions
If you have any questions, create an issue (protip: do a quick search first to see if someone else didn't ask the same question before!). You can also reach the owner/developers at our discord