TL;DR
The Chinese Text Project (ctext.org) API provides machine-readable access to the largest online repository of pre-modern Chinese texts. Retrieve full chapters from classics like the Analects (論語), Dao De Jing (道德經), I Ching (易經), historical records, medical texts, and philosophical works. Search by text name, passage keyword, or chapter number. Responses in JSON format with both original Chinese and English translations where available. No API key. Invaluable for sinologists, philosophy students, and historical researchers.
Quick start: https://api.ctext.org/retrieve/23215?format=json
No API key needed — just make a request!
How to Use This API
1. Retrieve a Text by ID
https://api.ctext.org/retrieve/23215?format=json
2. Search the Text Corpus
https://api.ctext.org/search?query=仁&format=json
3. JavaScript — Get a Confucius Chapter
fetch('https://api.ctext.org/retrieve/23215?format=json')
.then(r => r.json())
.then(data => {
console.log(`Title: ${data.title}`);
console.log(`Source: ${data.source}`);
console.log(`Paragraphs: ${data.paragraphs.length}`);
data.paragraphs.slice(0, 3).forEach((p, i) => {
console.log(`\nParagraph ${i+1}:`);
console.log(p.text);
});
});
4. Python — Compare Translations
import requests
# Get chapter 1 of the Analects
data = requests.get(
'https://api.ctext.org/retrieve/23215?format=json'
).json()
print(f"{data['title']} — {data['source']}\n")
for p in data['paragraphs'][:5]:
chinese = p.get('text', '')
english = p.get('translation', '')
if chinese:
print(f"中: {chinese}")
if english:
print(f"EN: {english}")
print()
https://api.ctext.org/retrieve/23215?format=json
Frequently Asked Questions
- What texts are available?
- Confucian classics (Four Books, Five Classics), Daoist texts (Laozi, Zhuangzi), historical records (Shiji, Zizhi Tongjian), medical texts (Huangdi Neijing), and hundreds of other pre-1911 Chinese works.
- How do I find text IDs?
- Browse ctext.org to find the text you need. The text ID appears in the URL. You can also use the search API to find texts by keyword.
- Are English translations included?
- Many major texts include English translations alongside the original Chinese. Translation availability varies by text. Check the
translationfield in responses. - What format does the API use?
- JSON format with
format=jsonparameter. The API also supports XML. Responses include text metadata, chapter/paragraph structure, and annotations. - Can I search within texts?
- Yes, the search API (
/search?query=) searches across the entire corpus and returns matching passages with context. Supports Chinese characters and pinyin. - Are there usage guidelines?
- The Chinese Text Project is an academic resource. Reasonable automated access is permitted for research and educational purposes. Cite appropriately.
API Details
- API URL
https://api.ctext.org- Documentation
- ctext.org/api
- Category
- Books
- Authentication
- Not Required
- Geographic Coverage
- Global (Pre-modern Chinese texts)
What You Can Build
- Classical Chinese philosophy reader with side-by-side original and translation
- Text analysis tool comparing usage of key concepts (仁, 道, 德) across different texts
- Quote generator extracting wisdom sayings from Confucian and Daoist sources
- Interactive timeline of Chinese philosophical schools and their major works
- Character frequency analyzer for Classical Chinese vocabulary building