2.9 KiB
2.9 KiB
Google Docs Routing Reference
App name: google-docs
Base URL proxied: docs.googleapis.com
API Path Pattern
/google-docs/v1/documents/{documentId}
Common Endpoints
Get Document
GET /google-docs/v1/documents/{documentId}
Create Document
POST /google-docs/v1/documents
Content-Type: application/json
{
"title": "New Document"
}
Batch Update Document
POST /google-docs/v1/documents/{documentId}:batchUpdate
Content-Type: application/json
{
"requests": [
{
"insertText": {
"location": {"index": 1},
"text": "Hello, World!"
}
}
]
}
Common Requests for batchUpdate
Insert Text
{
"insertText": {
"location": {"index": 1},
"text": "Text to insert"
}
}
Delete Content
{
"deleteContentRange": {
"range": {
"startIndex": 1,
"endIndex": 10
}
}
}
Replace All Text
{
"replaceAllText": {
"containsText": {
"text": "{{placeholder}}",
"matchCase": true
},
"replaceText": "replacement value"
}
}
Insert Table
{
"insertTable": {
"location": {"index": 1},
"rows": 3,
"columns": 3
}
}
Insert Inline Image
{
"insertInlineImage": {
"location": {"index": 1},
"uri": "https://example.com/image.png",
"objectSize": {
"height": {"magnitude": 100, "unit": "PT"},
"width": {"magnitude": 100, "unit": "PT"}
}
}
}
Update Text Style
{
"updateTextStyle": {
"range": {
"startIndex": 1,
"endIndex": 10
},
"textStyle": {
"bold": true,
"fontSize": {"magnitude": 14, "unit": "PT"}
},
"fields": "bold,fontSize"
}
}
Insert Page Break
{
"insertPageBreak": {
"location": {"index": 1}
}
}
Document Structure
The document body contains:
content- Array of structural elementsbody.content[].paragraph- Paragraph elementbody.content[].table- Table elementbody.content[].sectionBreak- Section break
Notes
- Authentication is automatic - the router injects the OAuth token
- Index positions are 1-based (document starts at index 1)
- Use
endOfSegmentLocationto append at end - Multiple requests in batchUpdate are applied atomically
- Get document first to find correct indices for updates
- The
fieldsparameter in style updates uses field mask syntax