Update readme
This commit is contained in:
42
API.md
Normal file
42
API.md
Normal file
@@ -0,0 +1,42 @@
|
||||
<p align="center">
|
||||
<img src=".github/banner.svg">
|
||||
</p>
|
||||
|
||||
# API
|
||||
paste has a simple HTTP API which can be used to read and write pastes programmatically.
|
||||
|
||||
> [!IMPORTANT]
|
||||
> If you are using the official instance of paste (https://pastes.dev), please note the following:
|
||||
>
|
||||
> * 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)`.
|
||||
> * 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.
|
||||
> * An additional **terms of service** applies. In summary:
|
||||
> * No Illegal Use *(no illegal, harmful or unlawful content)*
|
||||
> * No Malicious Content *(no malware, phishing, personal data without consent, etc.)*
|
||||
> * Content Responsibility *(you are responsible for what you post)*
|
||||
> * Moderation *(we reserve the right to remove content or block access)*
|
||||
> * No Liability *(the service is provided "as is" without warranties)*
|
||||
>
|
||||
> Otherwise, please enjoy using the service! :)
|
||||
|
||||
### Base URL
|
||||
The base URL for the 'official' paste instance is: `https://api.pastes.dev/`.
|
||||
|
||||
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/`.
|
||||
|
||||
## Upload: `POST {BASE URL}/post`
|
||||
|
||||
To upload content, send an HTTP `POST` request to `{BASE URL}/post`.
|
||||
|
||||
* Include the content in the request body.
|
||||
* Specify the language with the `Content-Type: text/<language>` header
|
||||
* If using the official instance, please remember to provide a suitable `User-Agent` header as well. (see above for more details)
|
||||
* The paste "key" is returned in the `Location` header, and in the response body as a JSON object in the format `{"key": "<key>"}`.**
|
||||
|
||||
## Read: `GET {BASE URL}/{key}`
|
||||
|
||||
To read content, send an HTTP `GET` request to `{BASE URL}/{key}`.
|
||||
|
||||
* Replace `{key}` with the id of the paste.
|
||||
* The content is returned in the response body.
|
||||
* The `Content-Type` header is `text/<language>`, where language is the id of the language the paste was saved with.
|
||||
38
README.md
38
README.md
@@ -23,18 +23,6 @@ You can submit content most easily using [curl](https://curl.se/docs/manpage.htm
|
||||
> echo "Hello world" | curl -T - https://api.pastes.dev/post
|
||||
```
|
||||
|
||||
<details>
|
||||
<summary>If curl isn't installed on your system, you can also post using <b>netcat</b>.</summary>
|
||||
|
||||
```shell
|
||||
# Pipe in some output from any command
|
||||
> echo "Hello world" | nc nc.pastes.dev 1337
|
||||
|
||||
# Upload the contents of a file
|
||||
> cat example.txt | nc nc.pastes.dev 1337
|
||||
```
|
||||
</details>
|
||||
|
||||
<details>
|
||||
<summary>If you don't want to do so much typing, you can create a shorter <b>alias</b>.</summary>
|
||||
|
||||
@@ -56,8 +44,8 @@ You can submit content most easily using [curl](https://curl.se/docs/manpage.htm
|
||||
```
|
||||
</details>
|
||||
|
||||
##### 3) From Code
|
||||
Send GET/POST/PUT requests to `https://api.pastes.dev/`. More info [below](#pastesdev-api).
|
||||
##### 3) From Code / Scripts
|
||||
Please see the [API Documentation](/API.md). :)
|
||||
|
||||
___
|
||||
|
||||
@@ -66,28 +54,6 @@ The frontend _(this repository)_ is written using the React framework. The backe
|
||||
|
||||
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!
|
||||
|
||||
### pastes.dev
|
||||
|
||||
I host a public instance at https://pastes.dev. Please feel free to use it to share code/configs/whatever!
|
||||
|
||||
Please note that the following (very-non-legally worded) [terms of service](https://github.com/lucko/bytebin#public-instances) apply.
|
||||
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.
|
||||
|
||||
Uploaded content is retained for 90 days then deleted.
|
||||
|
||||
### pastes.dev API
|
||||
|
||||
* To **read** content, send a HTTP `GET` request to `https://api.pastes.dev/<key>`.
|
||||
* Replace `<key>` with the id of the paste.
|
||||
* The content is returned in the response body.
|
||||
* The `Content-Type` header is `text/<language>`, where language is the id of the language the paste was saved with.
|
||||
* To **upload** content, send a HTTP `POST` request to `https://api.pastes.dev/post`.
|
||||
* Include the content in the request body.
|
||||
* Specify the language with the `Content-Type: text/<language>` header, and please provide a `User-Agent` header too.
|
||||
* The paste "key" is returned in the `Location` header, or in the response body as a JSON object in the format `{"key": "<key>"}`.
|
||||
|
||||
The API is powered by the [bytebin](https://github.com/lucko/bytebin) service, so more information about how it works can be found there.
|
||||
|
||||
___
|
||||
|
||||
### Self-hosting
|
||||
|
||||
@@ -30,6 +30,7 @@ export default function About({
|
||||
}: {
|
||||
setVisible: (show: boolean) => void;
|
||||
}) {
|
||||
const official = window.location.hostname === 'localhost';
|
||||
const [showTos, setShowTos] = useState<boolean>(false);
|
||||
|
||||
if (showTos) {
|
||||
@@ -47,7 +48,7 @@ export default function About({
|
||||
different take on conventional pastebin sites like pastebin.com or
|
||||
hastebin.
|
||||
</p>
|
||||
{window.location.hostname === 'pastes.dev' && (
|
||||
{official && (
|
||||
<>
|
||||
<p>
|
||||
<b>pastes.dev</b> is the official, publicly accessible paste
|
||||
@@ -65,7 +66,10 @@ export default function About({
|
||||
</p>
|
||||
<p>
|
||||
To access pastes.dev programmatically, please use the{' '}
|
||||
<a href="https://github.com/lucko/paste#readme" target="_blank">
|
||||
<a
|
||||
href="https://github.com/lucko/paste/blob/master/API.md"
|
||||
target="_blank"
|
||||
>
|
||||
API
|
||||
</a>
|
||||
. :)
|
||||
@@ -141,7 +145,7 @@ const Tos = ({ setVisible }: { setVisible: (show: boolean) => void }) => {
|
||||
abuse or violations of these terms.
|
||||
</li>
|
||||
<li>
|
||||
<b>No Guarantees:</b> This service is provided "as is" with no
|
||||
<b>No Liability:</b> This service is provided "as is" with no
|
||||
warranties. We do not guarantee uptime, data retention, or
|
||||
availability.
|
||||
</li>
|
||||
@@ -150,11 +154,10 @@ const Tos = ({ setVisible }: { setVisible: (show: boolean) => void }) => {
|
||||
By using pastes.dev, you accept these terms. If you do not agree, please
|
||||
do not use the service.
|
||||
</p>
|
||||
<h2>Reporting Abuse</h2>
|
||||
<p>
|
||||
<b>Reporting Abuse</b>
|
||||
<br />
|
||||
If you encounter illegal or malicious content, please report it by email
|
||||
to report-abuse {'<at>'} pastes.dev.
|
||||
to <span>report-abuse@pastes.dev</span>.
|
||||
</p>
|
||||
</AboutPanel>
|
||||
);
|
||||
@@ -173,6 +176,10 @@ const AboutPanel = styled.div`
|
||||
|
||||
color: ${props => props.theme.primary};
|
||||
background-color: ${props => props.theme.secondary};
|
||||
|
||||
span {
|
||||
color: ${props => props.theme.logo};
|
||||
}
|
||||
`;
|
||||
|
||||
const BannerContainer = styled.div`
|
||||
|
||||
Reference in New Issue
Block a user