Triangle.js Tetra Channel API

This is the documentation for the subsection of Triangle.js that interacts with the public https://ch.tetr.io/api api. For the full documentation, see the main README.

import { ch } from "@haelp/teto";

Or

// only load the required channel api module
import { ch } from "@haelp/teto/ch";
ch.setSessionID("your-session-id");
const id = ch.getSessionID();

There are 4 different types of requests that the api can make. Here is an explanation of each one:

These send no data to the server. Example:

const res = await ch.general.stats();

These send data in the form of arugments in the request uri. Example:

// This sends a request to https://ch.tetr.io/api/users/halp
const res = await ch.users.get("halp");

Or

const res = await ch.users.get({ user: halp });

These send data in the form of query parameters. Example:

// This sends a request to https://ch.tetr.io/api/news/?limit=100
const res = await ch.news.all({ limit: 100 });

These send data in the form of query parameters and arguments in the request uri. Example:

// This sends a request to https://ch.tetr.io/api/users/by/xp?limit=100
const res = await ch.users.leaderboard("xp", { limit: 100 });

View the official docs for more information on the api.