Skip to content

Commit f541510

Browse files
committed
docs: add English API examples and update link in README_EN
1 parent 71a8205 commit f541510

File tree

2 files changed

+133
-1
lines changed

2 files changed

+133
-1
lines changed

README_EN.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ Parameters:
102102
}
103103
```
104104

105-
> 📚 **More Examples**: Check out the [API Usage Examples](docs/api-examples.md) for detailed use cases and examples in various programming languages.
105+
> 📚 **More Examples**: Check out the [API Usage Examples](docs/api-examples_EN.md) for detailed use cases and examples in various programming languages.
106106
107107
## Project Structure
108108

docs/api-examples_EN.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
# API Usage Examples
2+
3+
## 1. Convert via URL
4+
5+
### GET Request
6+
```bash
7+
curl "https://anything-md.doocs.org/?url=https://example.com"
8+
```
9+
10+
### POST Request
11+
```bash
12+
curl -X POST https://anything-md.doocs.org/ \
13+
-H "Content-Type: application/json" \
14+
-d '{"url": "https://example.com"}'
15+
```
16+
17+
## 2. Direct Content Conversion
18+
19+
### Simple HTML Conversion
20+
```bash
21+
curl -X POST https://anything-md.doocs.org/ \
22+
-H "Content-Type: application/json" \
23+
-d '{
24+
"html": "<html><head><title>Example</title></head><body><h1>Hello World</h1><p>This is a test.</p></body></html>"
25+
}'
26+
```
27+
28+
### Using the `content` Parameter
29+
```bash
30+
curl -X POST https://anything-md.doocs.org/ \
31+
-H "Content-Type: application/json" \
32+
-d '{
33+
"content": "<html><body><h1>Test Page</h1><p>Content here.</p></body></html>",
34+
"contentType": "text/html",
35+
"fileName": "test-page.html"
36+
}'
37+
```
38+
39+
### JavaScript Example
40+
```javascript
41+
// Method 1: Using the html parameter
42+
const response1 = await fetch('https://anything-md.doocs.org/', {
43+
method: 'POST',
44+
headers: { 'Content-Type': 'application/json' },
45+
body: JSON.stringify({
46+
html: '<html><body><h1>Hello</h1></body></html>'
47+
})
48+
});
49+
50+
// Method 2: Using the content parameter
51+
const response2 = await fetch('https://anything-md.doocs.org/', {
52+
method: 'POST',
53+
headers: { 'Content-Type': 'application/json' },
54+
body: JSON.stringify({
55+
content: '<html><body><h1>Hello</h1></body></html>',
56+
contentType: 'text/html',
57+
fileName: 'my-page.html'
58+
})
59+
});
60+
61+
const data = await response2.json();
62+
console.log(data.markdown);
63+
```
64+
65+
### Python Example
66+
```python
67+
import requests
68+
69+
# Using the html parameter
70+
response = requests.post('https://anything-md.doocs.org/', json={
71+
'html': '<html><body><h1>Hello</h1><p>World</p></body></html>'
72+
})
73+
74+
print(response.json()['markdown'])
75+
76+
# Using the content parameter
77+
response = requests.post('https://anything-md.doocs.org/', json={
78+
'content': '<html><body><h1>Custom Title</h1></body></html>',
79+
'contentType': 'text/html',
80+
'fileName': 'custom.html'
81+
})
82+
83+
print(response.json())
84+
```
85+
86+
## 3. Get Raw Markdown (Without JSON Wrapping)
87+
88+
```bash
89+
# Via URL
90+
curl "https://anything-md.doocs.org/?url=https://example.com&format=raw"
91+
92+
# Direct content
93+
curl -X POST https://anything-md.doocs.org/ \
94+
-H "Content-Type: application/json" \
95+
-d '{
96+
"html": "<html><body><h1>Hello</h1></body></html>",
97+
"format": "raw"
98+
}'
99+
```
100+
101+
## Response Format
102+
103+
### JSON Response (Default)
104+
```json
105+
{
106+
"success": true,
107+
"url": "https://example.com",
108+
"name": "page.html",
109+
"mimeType": "text/html",
110+
"tokens": 0,
111+
"markdown": "# Example Domain\n\nThis domain is for use in illustrative examples..."
112+
}
113+
```
114+
115+
### Raw Markdown (format=raw)
116+
```markdown
117+
# Example Domain
118+
119+
This domain is for use in illustrative examples...
120+
```
121+
122+
## Parameter Reference
123+
124+
| Parameter | Type | Required | Description |
125+
|-----------|------|----------|-------------|
126+
| `url` | string | No* | URL of the page to convert |
127+
| `content` / `html` | string | No* | Content to convert directly (use one or the other) |
128+
| `contentType` | string | No | Content MIME type, defaults to `text/html` |
129+
| `fileName` | string | No | Output file name; for HTML the title is extracted automatically |
130+
| `format` | string | No | Set to `raw` to return plain Markdown text instead of JSON |
131+
132+
*Note: Either `url` or `content`/`html` must be provided.

0 commit comments

Comments
 (0)