Spacebin is a modern Pastebin server implemented in Go and 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.
Important
Try our public online version at https://spaceb.in!
Features:
- 99% self-contained: only requires a database to run.
- Raw text and code uploading
- Phrase and random string identifiers.
- Custom named documents that are always available.
- Configurable ratelimiting, expiration, compression, etc.
- Modern, JavaScript-free user interface
- Syntax highlighting for all the most popular languages and Raw text mode
- SQLite, MySQL, and PostgreSQL Support
- Basic Auth for private instances
- Password-protected encrypted pastes
- Paste collections
- Reader view mode (Markdown is formatted and word wrapping is enabled)
- QR Codes
Vote on future features: Image/file uploading, Account system
Looking for a URL shortener too? Try redeyes.
Tip
Need support? Visit our Discussions tab to get help from the community.
# Pull and run docker image on port 80
$ sudo docker pull spacebinorg/spirit
$ sudo docker run -d -e SPIRIT_CONNECTION_URI="sqlite://database.sqlite" -p 80:9000 spacebinorg/spirit
Use the following config file to host Spacebin via Docker Compose:
services:
spacebin:
image: spacebinorg/spirit:latest
restart: always
environment:
- SPIRIT_CONNECTION_URI=postgres://spacebin:password@postgres:5432/spacebin?sslmode=disable
ports:
- 9000:9000
depends_on:
- postgres
postgres:
image: postgres:16.3-alpine
restart: always
environment:
- POSTGRES_USER=spacebin
- POSTGRES_PASSWORD=password
- POSTGRES_DB=spacebin
volumes:
- postgres:/var/lib/postgresql/data
volumes:
postgres:
Important
Requires: Git, Go 1.22.4, GNU Makefile, and a SQLite, MySQL, or 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="sqlite://database.sqlite" ./bin/spirit # SQLite
$ SPIRIT_CONNECTION_URI="mysql://<your instance URI>?parseTime=true" ./bin/spirit
$ SPIRIT_CONNECTION_URI="postgres://<your PostgreSQL instance URI>" ./bin/spirit # PostgreSQL
# 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 | Database connection URI |
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 to SPACEBIN_
in the next major version.
Spacebin supports two database formats: SQLite and Postgres
- For SQLite, use either the scheme
file://
orsqlite://
and a file name.- Example:
file://database.db
- Example:
- For PostgreSQL, use the standard PostgreSQL URI format.
- For MySQL, use the DSN format prefixed with
mysql://
ormariadb://
- You must set the
parseTime
option to true; append?parseTime=true
to the end of the URI
- You must set the
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="$(cat 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- Accepts JSON and multipart/form-data
- For both formats, include document content in a
content
field - Only accepts POST requests
- Instances are able to specify a maximum document length.
spaceb.in
uses a 4MB maximum size.
- Successful requests return a JSON body with the following format:
{
"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 ID- Document ID lengths vary between instances. For
spaceb.in
, they will be exactly 8 characters. - Upon successful request, returns a JSON body with the following format:
{
"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 ID- Document ID lengths vary between instances. For
spaceb.in
, they will be exactly 8 characters - Returns a
plain/text
file containing the content of the document.
Tip
There are two additional non-API routes: /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 ([email protected]) 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.