Sign inSign up

fyko/export-api

By fyko

•Updated over 4 years ago

An API to export Discord channels as HTML documents

Image
2

1.2K

fyko/export-api repository overview

⁠📥 Discord Channel Exporter API

An API to create HTML exports of Discord text-channels

⁠Preface

This API utilized Tyrrrz/DiscordChatExporter⁠ for exporting channels.

⁠Usage

⁠Docker Image

The Export API can be found on the Docker Hub⁠ at fyko/export-api⁠.

⁠Using the Docker Image
docker run -p yourport:80 --rm -it fyko/export-api

or within Compose

services:
  exportapi:
    image: fyko/export-api
    ports:
      - "yourport:80"
    expose:
      - "yourport"
⁠Performing Requests

POST to /v1/export with the JSON body:

{
	"token": "discord bot token",
	"channelId": "guild channel id"
}
⁠Response Codes
StatusDescription
200Success - exported channel sent as text/html
401Unauthorized - bad Discord bot token
409Conflict - unknown channel
⁠Examples
⁠Typescript:
import fetch from 'node-fetch';

async function exportChannel(channelId: string, token: string): Promise<Buffer> {
	const response = await fetch('http://localhost:8008/v1/export', {
		method: 'POST',
		body: JSON.stringify({ channelId, token }),
		headers: {
			'Content-Type': 'application/json'
		}
	});
	if (response.ok) {
		return response.buffer();
	}
	throw Error('Channel export failed!');
}
⁠Rust
// reqwest = { version = "0.10", features = ["json"] }
use reqwest::Client;
use std::collections::HashMap;
use std::io::copy;
use std::fs::File;

async fn export_channel(channelId: &str, token: &str) -> Result<File, reqwest::Error> {
	let client = Client::new();
	let mut map = HashMap::new();
	map.insert("channelId", "channel id");
	map.insert("token", "discord token");

	let file = client.post("http://localhost:8008/v1/export").json(&map).await?.text().await?;

	let dest = File::create("myexport.html")?;
	copy(&mut file.as_bytes(), &mut dest)?;

	Ok(dest)
}

Tag summary

Content type

Image

Digest

Size

43.8 MB

Last updated

over 4 years ago

docker pull fyko/export-api