Skip to content

Commit 226b309

Browse files
committed
Update readme
1 parent 366013f commit 226b309

File tree

3 files changed

+57
-42
lines changed

3 files changed

+57
-42
lines changed

API.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<p align="center">
2+
<img src=".github/banner.svg">
3+
</p>
4+
5+
# API
6+
paste has a simple HTTP API which can be used to read and write pastes programmatically.
7+
8+
> [!IMPORTANT]
9+
> If you are using the official instance of paste (https://pastes.dev), please note the following:
10+
>
11+
> * You must **provide a `User-Agent` header** to uniquely identify your application in all requests. This should include the application name and contact information, e.g. `ExampleApp (github.com/ExampleUser/ExampleApp)` or `MyExampleScript (github.com/ExampleUser)`.
12+
> * You must **only upload content when prompted by a user action**, e.g. a button click or command line input. Automated or scheduled uploads are not allowed.
13+
> * An additional **terms of service** applies. In summary:
14+
> * No Illegal Use *(no illegal, harmful or unlawful content)*
15+
> * No Malicious Content *(no malware, phishing, personal data without consent, etc.)*
16+
> * Content Responsibility *(you are responsible for what you post)*
17+
> * Moderation *(we reserve the right to remove content or block access)*
18+
> * No Liability *(the service is provided "as is" without warranties)*
19+
>
20+
> Otherwise, please enjoy using the service! :)
21+
22+
### Base URL
23+
The base URL for the 'official' paste instance is: `https://api.pastes.dev/`.
24+
25+
If you are self-hosting, use the base URL of your own instance. With the default Docker Compose setup, this will be `http://localhost:8080/data/`.
26+
27+
## Upload: `POST {BASE URL}/post`
28+
29+
To upload content, send an HTTP `POST` request to `{BASE URL}/post`.
30+
31+
* Include the content in the request body.
32+
* Specify the language with the `Content-Type: text/<language>` header
33+
* If using the official instance, please remember to provide a suitable `User-Agent` header as well. (see above for more details)
34+
* The paste "key" is returned in the `Location` header, and in the response body as a JSON object in the format `{"key": "<key>"}`.**
35+
36+
## Read: `GET {BASE URL}/{key}`
37+
38+
To read content, send an HTTP `GET` request to `{BASE URL}/{key}`.
39+
40+
* Replace `{key}` with the id of the paste.
41+
* The content is returned in the response body.
42+
* The `Content-Type` header is `text/<language>`, where language is the id of the language the paste was saved with.

README.md

Lines changed: 2 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,6 @@ You can submit content most easily using [curl](https://curl.se/docs/manpage.htm
2323
> echo "Hello world" | curl -T - https://api.pastes.dev/post
2424
```
2525

26-
<details>
27-
<summary>If curl isn't installed on your system, you can also post using <b>netcat</b>.</summary>
28-
29-
```shell
30-
# Pipe in some output from any command
31-
> echo "Hello world" | nc nc.pastes.dev 1337
32-
33-
# Upload the contents of a file
34-
> cat example.txt | nc nc.pastes.dev 1337
35-
```
36-
</details>
37-
3826
<details>
3927
<summary>If you don't want to do so much typing, you can create a shorter <b>alias</b>.</summary>
4028

@@ -56,8 +44,8 @@ You can submit content most easily using [curl](https://curl.se/docs/manpage.htm
5644
```
5745
</details>
5846

59-
##### 3) From Code
60-
Send GET/POST/PUT requests to `https://api.pastes.dev/`. More info [below](#pastesdev-api).
47+
##### 3) From Code / Scripts
48+
Please see the [API Documentation](/API.md). :)
6149

6250
___
6351

@@ -66,28 +54,6 @@ The frontend _(this repository)_ is written using the React framework. The backe
6654

6755
The user-interface is based on the [Monaco Editor](https://microsoft.github.io/monaco-editor/), the engine behind the popular Visual Studio Code text editor. It's quite simple; it supports syntax highlighting, automatic indentation, many supported languages, themes, zooming in/out, linking to specific lines or sections, and more!
6856

69-
### pastes.dev
70-
71-
I host a public instance at https://pastes.dev. Please feel free to use it to share code/configs/whatever!
72-
73-
Please note that the following (very-non-legally worded) [terms of service](https://github.com/lucko/bytebin#public-instances) apply.
74-
If you come across any content which is illegal or infringes on copyright, please [get in touch](https://lucko.me/contact) and let me know so I can remove it.
75-
76-
Uploaded content is retained for 90 days then deleted.
77-
78-
### pastes.dev API
79-
80-
* To **read** content, send a HTTP `GET` request to `https://api.pastes.dev/<key>`.
81-
* Replace `<key>` with the id of the paste.
82-
* The content is returned in the response body.
83-
* The `Content-Type` header is `text/<language>`, where language is the id of the language the paste was saved with.
84-
* To **upload** content, send a HTTP `POST` request to `https://api.pastes.dev/post`.
85-
* Include the content in the request body.
86-
* Specify the language with the `Content-Type: text/<language>` header, and please provide a `User-Agent` header too.
87-
* The paste "key" is returned in the `Location` header, or in the response body as a JSON object in the format `{"key": "<key>"}`.
88-
89-
The API is powered by the [bytebin](https://github.com/lucko/bytebin) service, so more information about how it works can be found there.
90-
9157
___
9258

9359
### Self-hosting

src/components/About.tsx

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export default function About({
3030
}: {
3131
setVisible: (show: boolean) => void;
3232
}) {
33+
const official = window.location.hostname === 'localhost';
3334
const [showTos, setShowTos] = useState<boolean>(false);
3435

3536
if (showTos) {
@@ -47,7 +48,7 @@ export default function About({
4748
different take on conventional pastebin sites like pastebin.com or
4849
hastebin.
4950
</p>
50-
{window.location.hostname === 'pastes.dev' && (
51+
{official && (
5152
<>
5253
<p>
5354
<b>pastes.dev</b> is the official, publicly accessible paste
@@ -65,7 +66,10 @@ export default function About({
6566
</p>
6667
<p>
6768
To access pastes.dev programmatically, please use the{' '}
68-
<a href="https://github.com/lucko/paste#readme" target="_blank">
69+
<a
70+
href="https://github.com/lucko/paste/blob/master/API.md"
71+
target="_blank"
72+
>
6973
API
7074
</a>
7175
. :)
@@ -141,7 +145,7 @@ const Tos = ({ setVisible }: { setVisible: (show: boolean) => void }) => {
141145
abuse or violations of these terms.
142146
</li>
143147
<li>
144-
<b>No Guarantees:</b> This service is provided "as is" with no
148+
<b>No Liability:</b> This service is provided "as is" with no
145149
warranties. We do not guarantee uptime, data retention, or
146150
availability.
147151
</li>
@@ -150,11 +154,10 @@ const Tos = ({ setVisible }: { setVisible: (show: boolean) => void }) => {
150154
By using pastes.dev, you accept these terms. If you do not agree, please
151155
do not use the service.
152156
</p>
157+
<h2>Reporting Abuse</h2>
153158
<p>
154-
<b>Reporting Abuse</b>
155-
<br />
156159
If you encounter illegal or malicious content, please report it by email
157-
to report-abuse {'<at>'} pastes.dev.
160+
to <span>report-abuse@pastes.dev</span>.
158161
</p>
159162
</AboutPanel>
160163
);
@@ -173,6 +176,10 @@ const AboutPanel = styled.div`
173176
174177
color: ${props => props.theme.primary};
175178
background-color: ${props => props.theme.secondary};
179+
180+
span {
181+
color: ${props => props.theme.logo};
182+
}
176183
`;
177184

178185
const BannerContainer = styled.div`

0 commit comments

Comments
 (0)