Skip to main content

v2 (discontinued)

API Discontinued

This API version is discontinued, it's advised you use gRPC.

Export Formats Enum

TypeIDDescriptionFile Extension
PlainText0Export to a plaintext filetxt
HtmlDark1Export to an HTML file in dark modehtml
HtmlLight2Export to an HTML file in light modehtml
CSV3Export to a comma separated values filecsv
JSON4Export to a JSON filejson

POST /v2/export

Exports a channel. On success, it returns a file stream.

JSON Body

FieldTypeDescription
tokenstringThe bot token for performing requests
channel_idstringThe id of the channel to export
export_format?ExportFormatThe format to export the channel as, defaults to HtmlDark
date_format?stringThe date format for dates in exported files, defaults to dd-MMM-yy hh:mm tt
after?stringOnly include messages sent after this date
before?stringOnly include messages sent before this date

Examples

Typescript:

import fetch from 'node-fetch';

async function exportChannel(channel_id: string, token: string): Promise<Buffer> {
const response = await fetch('http://exportapi:80/v2/export', {
method: 'POST',
body: JSON.stringify({ channel_id, 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("channel_id", "channel id");
map.insert("token", "discord token");

let file = client.post("http://exportapi:80/v2/export").json(&map).await?.text().await?;

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

Ok(dest)
}