Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/brecert/revolt-api
a typed revolt api client
https://github.com/brecert/revolt-api
deno javascript revolt revolt-api-wrapper types typrescript
Last synced: 3 days ago
JSON representation
a typed revolt api client
- Host: GitHub
- URL: https://github.com/brecert/revolt-api
- Owner: brecert
- Created: 2022-04-06T21:00:33.000Z (almost 3 years ago)
- Default Branch: main
- Last Pushed: 2022-05-04T10:17:43.000Z (over 2 years ago)
- Last Synced: 2024-12-17T08:52:46.966Z (22 days ago)
- Topics: deno, javascript, revolt, revolt-api-wrapper, types, typrescript
- Language: TypeScript
- Homepage:
- Size: 71.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Revolt API
[![revolt-api](https://img.shields.io/npm/v/@brecert/revolt-api)](https://www.npmjs.com/package/@brecert/revolt-api) [![deno module](https://shield.deno.dev/x/revolt_api)](https://deno.land/x/revolt_api)
This package contains typings for objects in the [Revolt API](https://developers.revolt.chat/api/) and a fully typed API request builder.
# Usage
You can find more info in the [documentation](https://doc.deno.land/https://deno.land/x/[email protected]/mod.ts).
```ts
import * as Revolt from "https://deno.land/x/revolt_api/mod.ts";const api = new Revolt.APIClient({
base: "https://api.revolt.chat",
headers: {
"x-bot-token": REVOLT_TOKEN,
"content-type": "application/json",
},
});const config = await api.get("Query Node", "/");
console.log(`The API is running revolt ${config.revolt}`);const me = await api.get("Fetch Self", "/users/@me");
console.log(`My ID is ${me._id}`);const channel_id = "some channel id";
await api.post("Send Message", `/channels/${channel_id}/messages`, {
body: {
content: "Hello!",
},
});
```# Building and Updating
```console
$ curl https://raw.githubusercontent.com/revoltchat/api/master/OpenAPI.json > OpenAPI.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 205k 100 205k 0 0 868k 0 --:--:-- --:--:-- --:--:-- 873k$ npx openapi-typescript OpenAPI.json -o schema.ts
✨ openapi-typescript 5.2.0
🚀 OpenAPI.json -> /revolt-api/schema.ts [417ms]$ deno run -A ./scripts/generate_routes.ts -i OpenAPI.json -o .\routes.ts
$ deno run -A ./scripts/export_types.ts -i OpenAPI.json -o .\types.ts
# build npm package
$ deno run -A ./scripts/build_npm.ts
```