Skip to content

Commit c741ff8

Browse files
committed
docs(readme.md): api documentation
1 parent 70fb178 commit c741ff8

File tree

2 files changed

+44
-3
lines changed

2 files changed

+44
-3
lines changed

README.md

+43-2
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ WIP
4949

5050
#### On the Web
5151

52-
To use Spacebin on the web, our team provides a web app written in [Svelte](https://svelte.dev): [Pulsar](https://github.com/orca-group/pulsar). A public instance of Spacebin using this client is available at [https://spaceb.in](https://spaceb.in) (the `/api` route can be used to access Spirit itself).
52+
To use Spacebin on the web, our team provides a web app. You can access the web app at [spaceb.in](https://spaceb.in). You must use `https://spaceb.in/api` to access the API routes.
5353

5454
#### CLI
5555

@@ -69,7 +69,48 @@ curl -v -F content=@helloworld.txt https://spaceb.in/ | jq payload.id
6969

7070
### API
7171

72-
Work in progress. Check out the documentation website: [docs.spaceb.in](https://docs.spaceb.in).
72+
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.
73+
74+
* `/api/`: Create Document
75+
* Accepts JSON and multipart/form-data
76+
* For both formats, include document content in a `content` field
77+
* Only accepts POST requests
78+
* Instances are able to specify a maximum document length.
79+
* `spaceb.in` uses a 4MB maximum size.
80+
* Successful requests return a JSON body with the following format:
81+
```json
82+
{
83+
"error": "",
84+
"payload": {
85+
"id": "WfwKGJfs",
86+
"content": "hello",
87+
"created_at": "2023-08-06T00:01:33.143532-04:00",
88+
"updated_at": "2023-08-06T00:01:33.143532-04:00"
89+
}
90+
}
91+
```
92+
* `/api/{document}`: Fetch Document
93+
* `{document}` = Document ID
94+
* Document ID lengths vary between instances. For `spaceb.in`, they will be exactly characters.
95+
*
96+
* Upon successful request, returns a JSON body with the following format:
97+
```json
98+
{
99+
"error": "",
100+
"payload": {
101+
"id": "WfwKGJfs",
102+
"content": "hello",
103+
"created_at": "2023-08-06T00:01:33.143532-04:00",
104+
"updated_at": "2023-08-06T00:01:33.143532-04:00"
105+
}
106+
}
107+
```
108+
* `/api/{document}/raw`: Fetch Document - Raw
109+
* `{document}` = Document ID
110+
* Document ID lengths vary between instances. For `spaceb.in`, they will be exactly 8 characters
111+
* Returns a `plain/text` file containing the content of the document.
112+
113+
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.
73114

74115
## Credits
75116

internal/server/web/index.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
</svg>
4444
</a>
4545

46-
<a id="wiki" href="https://docs.spaceb.in" aria-label="Spacebin Documentation">
46+
<a id="wiki" href="https://github.com/orca-group/spirit/blob/main/README.md/#-spirit" aria-label="Spacebin Documentation">
4747
<svg fill="none" height="24" stroke="currentColor" stroke-linecap="round" stroke-linejoin="round"
4848
stroke-width="2" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg">
4949
<path d="M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z" />

0 commit comments

Comments
 (0)