| name | gitbook-3-content-management |
| description | Sub-skill of gitbook: 3. Content Management (+1). |
| version | 1.0.0 |
| category | development |
| type | reference |
| scripts_exempt | true |
3. Content Management (+1)
3. Content Management
REST API - Content:
curl -s -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/spaces/SPACE_ID/content/page/PAGE_ID" | jq
curl -s -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/spaces/SPACE_ID/content" | jq '.pages'
curl -s -X POST -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
-H "Content-Type: application/json" \
"$API_BASE/spaces/SPACE_ID/content/import/git" \
-d '{
"url": "https://github.com/user/docs-repo",
"ref": "main"
}' | jq
curl -s -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/spaces/SPACE_ID/content/export" \
-o content-export.zip
curl -s -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/spaces/SPACE_ID/search?query=installation" | jq
Python - Content:
class GitBookClient:
def get_page(self, space_id, page_id):
"""Get page content."""
return self._request(
"GET",
f"/spaces/{space_id}/content/page/{page_id}"
)
def list_pages(self, space_id):
"""List all pages in space."""
content = self.get_space_content(space_id)
return content.get("pages", [])
def search_content(self, space_id, query):
"""Search content in space."""
return self._request(
"GET",
f"/spaces/{space_id}/search",
params={"query": query}
)
def import_from_git(self, space_id, repo_url, ref="main"):
"""Import content from Git repository."""
return self._request(
"POST",
f"/spaces/{space_id}/content/import/git",
data={"url": repo_url, "ref": ref}
)
results = client.search_content("space_xxxxx", "getting started")
result results.get(, []):
()
4. Collections Management
REST API - Collections:
curl -s -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/orgs/ORG_ID/collections" | jq
curl -s -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/collections/COLLECTION_ID" | jq
curl -s -X POST -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
-H "Content-Type: application/json" \
"$API_BASE/orgs/ORG_ID/collections" \
-d '{
"title": "Product Documentation",
"description": "All product-related documentation"
}' | jq
curl -s -X POST -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/collections/COLLECTION_ID/spaces/SPACE_ID" | jq
curl -s -X DELETE -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/collections/COLLECTION_ID/spaces/SPACE_ID"
curl -s -H "Authorization: Bearer $GITBOOK_API_TOKEN" \
"$API_BASE/collections/COLLECTION_ID/spaces" | jq
Python - Collections:
class GitBookClient:
def list_collections(self, org_id):
"""List all collections in organization."""
return self._request("GET", f"/orgs/{org_id}/collections")
def get_collection(self, collection_id):
"""Get collection details."""
return self._request("GET", f"/collections/{collection_id}")
def create_collection(self, org_id, title, description=None):
"""Create a new collection."""
data = {"title": title}
if description:
data["description"] = description
return self._request(
"POST",
f"/orgs/{org_id}/collections",
data=data
)
def add_space_to_collection(self, collection_id, space_id):
"""Add space to collection."""
return self._request(
"POST",
f"/collections/{collection_id}/spaces/{space_id}"
)
def list_collection_spaces():
._request(
,
)
collection = client.create_collection(
org_id=,
title=,
description=
)
client.add_space_to_collection(collection[], )