Skip to content

Commit b56800f

Browse files
committed
docs(README): add documentation on how to use the api
1 parent 2a23672 commit b56800f

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

README.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ docker run --rm -p 8080:8080 -v /tmp:/tmp ghcr.io/danvergara/morphos-server:late
4444

4545
## Usage
4646

47+
### HTML form
48+
4749
Run the server as mentioned above and open up your favorite browser. You'll see something like this:
4850

4951
<img src="screenshots/morphos.png"/>
@@ -68,6 +70,36 @@ A modal will pop up with a preview of the converted image.
6870

6971
<img src="screenshots/modal_morphos.png"/>
7072

73+
### API
74+
75+
You can consume morphos through an API, so other systems can integrate with it.
76+
77+
##### Endpoints
78+
79+
`GET /api/v1/formats`
80+
81+
This returns a JSON that shows the supported formats at the moment.
82+
83+
e.g.
84+
85+
```
86+
{"documents": ["docx", "xls"], "image": ["png", "jpeg"]}
87+
```
88+
89+
`POST /api/v1/upload`
90+
91+
This is the endpoint that converts files to a desired format. It is basically a multipart form data in a POST request. The API simply writes the converted files to the response body.
92+
93+
e.g.
94+
95+
```
96+
curl -F 'targetFormat=epub' -F 'uploadFile=@/path/to/file/foo.pdf' localhost:8080/api/v1/upload --output foo.epub
97+
```
98+
The form fields are:
99+
100+
* targetFormat: the target format the file will be converted to
101+
* uploadFile: The path to the file that is going to be converted
102+
71103
### Configuration
72104

73105
The configuration is only done by the environment varibles shown below.

0 commit comments

Comments
 (0)