Skip to content

A TypeScript library that contains API handlers for the Torrust Index project.

License

Apache-2.0, MIT-0 licenses found

Licenses found

Apache-2.0
LICENSE-APACHE_2_0
MIT-0
LICENSE-MIT_0
Notifications You must be signed in to change notification settings

torrust/torrust-index-api-lib

Repository files navigation

Torrust Index Application Interface

Test

A simple TypeScript/ES6 library that contains API calls used by the Torrust Index project.

Install

You can install this library using NPM:

npm i -S torrust-index-api-lib torrust-index-types-lib

Then import either the Rest or GraphQL (WIP) API library:

Rest

import {rest} from "torrust-index-api-lib";

GraphQL

import {graphql} from "torrust-index-api-lib";

Usage (Rest)

Torrent

Example of retrieving a single torrent using its torrent_id:

import {rest} from "torrust-index-api-lib";
import {Torrent} from "torrust-index-types-lib";

const API_BASE_URL = "http://localhost:3000";
let torrentId = 1;

rest.torrent.getTorrent(API_BASE_URL, torrentId)
    .then((torrent) => {
        // torrent has type Torrent
        console.log(torrent);
    })
    .catch((err) => {
        console.error(err);
    });

Usage (GraphQL)

The GraphQL API still needs to be developed.