This is a simple streaming (WebSocket) API, providing a live feed of (public) pastes as they are submitted to Pastebin.com. You can find the source code here.
Since Pastebin does not offer a streaming API itself, this API works by regularly polling the Pastebin API for new posts. This means that posts may be delayed by about a minute, and that they'll be broadcast in 'batches'.
February 9, 2018: Resolved a bug that produced an unexpected error when a client sent invalid data.
Note that the application kills and restarts itself as a safety precaution when an unexpected error is encountered; if you experienced crashes while trying to use the API yesterday, those issues should now be resolved.
The latest pastes:
None. But this is a non-commercial and free service, so please be reasonable, and consider donating if this service helped you out in some way!
Yes. Cross-domain connections are allowed. But again, be reasonable - if you expect to be making hundreds or thousands of simultaneous connections, please run your own proxy.
If you like this service, help keep it running by making a donation!
Please send your donation to 13quzALQ98dpJLPVcVA1rbEbE9Brf6VKyc :)
In the future, I will likely add support for other Pastebin services as well. Suggestions are welcome - send me an e-mail!
If you need to reach me for some reason, you can e-mail me at admin@cryto.net.
This API exposes a single endpoint, at wss://pastebin-stream.cryto.net/stream
. Every command below is meant to be sent through that connection. The server expects well-formed JSON, and will kill a connection if it sends malformed data.
No special clients are required; you can simply use the standard WebSocket API in browsers. For Node.js, I recommend using the ws
library. For other languages, simply use whichever WebSocket implementation is available to you.
The server sends out a 'ping' roughly every 5 seconds. If you wish to detect disconnections, this is what you'll want to check for.
The server maintains a backlog of pastes. The exact amount is subject to change, but assume "several hundred". You can make a backlog request to obtain these pastes from the backlog.
When connecting for the first time, you should do the following to obtain the maximum amount of pastes and make sure you're not left with a gap:
newPaste
events (immediately storing pastes once they start coming in).newPaste
events, and then insert the backlog before the already-received pastes.The API also includes a counter
property with every paste. This is an incrementing counter managed by the server, that can be used to obtain missed pastes after a reconnect.
If you've detected a connection loss and initiated a new connection, you should do the following to obtain all the pastes you missed:
newPaste
events (immediately storing pastes once they start coming in).since
parameter - it should contain the counter
of the last paste you've received on the previous connection.newPaste
events, and then insert the backlog before the already-received pastes.Note that when the server restarts, the counter
values will be reset to zero. This means that a given counter
value is only unique until the next server restart.
A paste object looks like the following:
{ "counter": 521, "service": "pastebinCom", "id": "V2rpgLwN", "title": "Paste Title Goes Here", "date": 1489876199, "expiry": 0, "language": "text", "url": "http://pastebin.com/gPifdLrb" "contents": "[ ... paste contents go here ... ]" }
An explanation of each of the properties:
pastebinCom
is the only option here.Any optional properties may be missing. You should take this into account in your implementation.
{ "type": "subscribe" }
You should send this immediately after connecting. Once you do, you will start receiving pastes. Incoming pastes look like the following:
{ "type": "newPaste", "data": <a single paste object goes here> }
There are a few options for request a backlog, but the response is always in the same format:
{ "type": "backlog", "results": [ ... an array of paste objects goes here ... ] }
This retrieves every single paste that the server has in its backlog. Note that the response may be large.
{ "type": "backlog", "all": true }
This retrieves only the last X entries in the backlog, where X is an amount you specify.
{ "type": "backlog", "last": 25 }
This retrieves every paste in the backlog since a given counter
value.
{ "type": "backlog", "since": 51291 }