Spacebin is a modern Pastebin server implemented in Go and maintained by Luke Whritenour. It is capable of serving notes, novels, code, or any other form of text! Spacebin was designed to be fast and reliable, avoiding the problems of many current pastebin servers. Spacebin features JavaScript-based text highlighting, but works completely fine with JS disabled. Besides text highlighting, we have many more features in the works. It is entirely self-hostable, and available in a Docker image.
Pastebins are a type of online content storage service where users can store plain text document, e.g. program source code. For more information and the history of Pastebin see Wikipedia's article on them.
Features:
[!TIP] > Try our public online version at https://spaceb.in!
# Pull and run docker image on port 80
$ sudo docker pull spacebinorg/spirit
$ sudo docker run -d -p 80:9000 spacebinorg/spirit
[!IMPORTANT] > Requires: Git, Go 1.22.4, GNU Makefile, and a PostgreSQL server.
# Clone the Github repository
$ git clone https://github.com/lukewhrit/spacebin.git
$ cd spacebin
# Build the binary
$ make spirit
# Start Spacebin
$ SPIRIT_CONNECTION_URI="<your PostgreSQL instance URI>" ./bin/spirit
# Success! Spacebin is now available at port 9000 on your machine.
Variable Name | Type | Default | Description |
---|---|---|---|
SPIRIT_HOST |
String | 0.0.0.0 |
Host address to listen on |
SPIRIT_PORT |
Int | 9000 |
HTTP port to listen on |
SPIRIT_RATELIMITER |
String | 200x5 |
Requests allowed per second before the user is ratelimited |
SPIRIT_CONNECTION_URI |
String | Required | PostgreSQL Database URI String |
SPIRIT_HEADLESS |
Bool | False |
Enables/disables the web interface |
SPIRIT_ANALYTICS |
String | "" |
<script> tag for analytics (leave blank to disable) |
SPIRIT_ID_LENGTH |
Int | 8 |
Length for document IDs |
SPIRIT_ID_TYPE |
"key" or "phrase" |
key |
Format of IDs: key is a random string of letters and phrase is a combination of words |
SPIRIT_MAX_SIZE |
Int | 400000 |
Max allowed size of a document in bytes |
SPIRIT_EXPIRATION_AGE |
Int64 | 720 |
Amount of time to expire documents after |
SPIRIT_DOCUMENTS |
[]String | [] |
List of any custom documents to serve |
[!WARNING] Environment variables for Spacebin are prefixed with
SPIRIT_
. They will be updated toSPACEBIN_
in the next major version.
To use Spacebin on the web, our team provides a web app. You can access the web app at spaceb.in. You must use https://spaceb.in/api
to access the API routes.
A version of spacebin that is built directly from the develop
branch is also available at **staging.spaceb.in
Since Spirit supports multipart/form-data
uploads, it's extremely easy to use on the command line via curl
. The scripts also use jq
so that you can get a machine-readable version of the document's ID, instead of a lengthy JSON object.
To upload a string of text:
curl -v -F content="Hello, world!" https://spaceb.in/ | jq payload.id
To upload from a file:
curl -v -F content=@helloworld.txt https://spaceb.in/ | jq payload.id
There are three primary API routes to: create a document, fetch a documents text content in JSON format, and fetch a documents plain text content.
/api/
: Create Document
content
fieldspaceb.in
uses a 4MB maximum size.{
"error": "",
"payload": {
"id": "WfwKGJfs",
"content": "hello",
"created_at": "2023-08-06T00:01:33.143532-04:00",
"updated_at": "2023-08-06T00:01:33.143532-04:00"
}
}
/api/{document}
: Fetch Document
{document}
= Document IDspaceb.in
, they will be exactly 8 characters.{
"error": "",
"payload": {
"id": "WfwKGJfs",
"content": "hello",
"created_at": "2023-08-06T00:01:33.143532-04:00",
"updated_at": "2023-08-06T00:01:33.143532-04:00"
}
}
/api/{document}/raw
: Fetch Document - Raw
{document}
= Document IDspaceb.in
, they will be exactly 8 charactersplain/text
file containing the content of the document.[!TIP] There are two additional non-API routes that are documented:
/ping
: returns a 200 OK if the service is online, and/config
: returns a JSON body with the instances configuration settings.
Spacebin is a project designed and maintained by Luke Whritenour. Spacebin started out as a fork of hastebin. Although it no longer contains any code from the original, we'd like to acknowledge our roots regardless.
Spacebin itself is built using Go and various libraries (i.e. Chi, pq, Ozzo Validation, Cron, env).
A full list of code contributors is available on Github. We'd also like to thank @jackdorland for designing our logo/brand.
The Spacebin team takes security very seriously. If you detect a vulnerability please contact us via email (hello@spaceb.in) or create a vulnerability report via Github. We request that you hold of on publishing any vulnerabilities until after they've been patched, or at least 60 days have passed since you reported it.
Spacebin is licensed under the Apache 2.0 license. A copy of this license can be found within the LICENSE
file.