A simple TypeScript/ES6 library that contains API calls used by the Torrust Index project.
- Torrust Index Backend is our reference implementation of this interface.
- Torrust Index Frontend is our reference web-application that consumes this interface.
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:
import {rest} from "torrust-index-api-lib";
import {graphql} from "torrust-index-api-lib";
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);
});
The GraphQL API still needs to be developed.