Skip to content

Paste site API

tom5454 edited this page Aug 3, 2024 · 5 revisions

Paste site API

Endpoints

API url: https://paste.tom5454.com/
Full implenetation in Java: PasteClient in CPM

Download

URL: raw/<paste_id>

Connect

URL: api/connect?name=<username>
Response: (JSON)

  • id: Session id, required in future requests
  • key: Minecraft Join Server key

Run minecraft's join server api. This is the same authentication that Minecraft uses when you join a Minecraft server.
URL: https://sessionserver.mojang.com/session/minecraft/join
POST request required
Post body: (JSON object)

  • accessToken: Minecraft account access token
  • selectedProfile: Minecraft account uuid as string (without - characters)
  • serverId: server id calculated with key

Calculating the serverId:
SHA-1 hash: tom5454-paste, <session id>, and <key> as ascii string then toString the result as hex number. Java example code:

	byte[] mojKey = Base64.getDecoder().decode(key);//key string from api
	//SHA-1 digest all of the data
	byte[] mojangKey = digestData("tom5454-paste".getBytes(), session.getBytes(), mojKey);
	String serverId = new BigInteger(mojangKey).toString(16);

Call Authenticate to finish setting up the session.

Authenticate

URL: api/session
HTTP headers:

  • Session:

Response: (JSON)
Empty JSON on success

List

URL: api/list
HTTP headers:

  • Session:

Auth required
Response: (JSON)

  • files (Array of Objects)
    (each object)
    • id: paste id
    • name: Paste name
    • time: upload time as string in ms UTC time
  • maxSize
  • maxFiles

Upload

URL: api/upload
HTTP headers:

  • Session:
  • Content-Length: Length of file
  • File-Name: Paste name

Auth required
POST request required
Post body: paste content
Response: (JSON)

  • id: new random paste id for the paste

Delete

URL: api/delete?file=<paste_id>
HTTP headers:

  • Session:

Auth required
Response: (JSON)
Empty JSON on success

Update

URL: api/update?file=<paste_id>
HTTP headers:

  • Session:
  • Content-Length: Length of file

Auth required
POST request required
Post body: paste content
Response: (JSON)
Empty JSON on success

Browser Login

URL: api/browser_login HTTP headers:

  • Session:

Auth required
Response: (JSON)

  • id: browser login token valid for 5 minutes, usable with /login.html?id=<id> site

App Login

URL: api/app_login HTTP headers:

  • AppID:

Response: (JSON)

  • id: application login token valid for 5 minutes, usable with /auth.html?id=<id> site

App Check

URL: api/app_check HTTP headers:

  • AppID:
  • Session:

Response: (JSON)

  • id: paste application token or
  • empty JSON if not authorized yet

App Token Request

URL: api/app_token_req HTTP headers:

  • AppID:
  • Session:

Response: (JSON)

Error messages

Respose: (JSON)

  • error: Human readable error message
  • errorMessage: Translation key for error message