Skip to content

Commit a31ff0f

Browse files
authored
Merge pull request #7095 from readthedocs/humitos/embed-api-v2-docs
Document Embed APIv2 endpoint
2 parents 97caf50 + c39879e commit a31ff0f

File tree

1 file changed

+79
-0
lines changed

1 file changed

+79
-0
lines changed

docs/api/v2.rst

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,85 @@ Build detail
317317

318318
Some fields primarily used for UI elements in Read the Docs are omitted.
319319

320+
321+
Embed
322+
~~~~~
323+
324+
.. http:get:: /api/v2/embed/
325+
326+
Retrieve HTML-formatted content from documentation page or section.
327+
328+
**Example request**:
329+
330+
.. prompt:: bash $
331+
332+
curl https://readthedocs.org/api/v2/embed/?project=docs&version=latest&doc=features&path=features.html
333+
334+
or
335+
336+
.. prompt:: bash $
337+
338+
curl https://readthedocs.org/api/v2/embed/?url=https://docs.readthedocs.io/en/latest/features.html
339+
340+
**Example response**:
341+
342+
.. sourcecode:: js
343+
344+
{
345+
"content": [
346+
"<div class=\"section\" id=\"read-the-docs-features\">\n<h1>Read the Docs..."
347+
],
348+
"headers": [
349+
{
350+
"Read the Docs features": "#"
351+
},
352+
{
353+
"Automatic Documentation Deployment": "#automatic-documentation-deployment"
354+
},
355+
{
356+
"Custom Domains & White Labeling": "#custom-domains-white-labeling"
357+
},
358+
{
359+
"Versioned Documentation": "#versioned-documentation"
360+
},
361+
{
362+
"Downloadable Documentation": "#downloadable-documentation"
363+
},
364+
{
365+
"Full-Text Search": "#full-text-search"
366+
},
367+
{
368+
"Open Source and Customer Focused": "#open-source-and-customer-focused"
369+
}
370+
],
371+
"url": "https://docs.readthedocs.io/en/latest/features",
372+
"meta": {
373+
"project": "docs",
374+
"version": "latest",
375+
"doc": "features",
376+
"section": "read the docs features"
377+
}
378+
}
379+
380+
:>json string content: HTML content of the section.
381+
:>json object headers: section's headers in the document.
382+
:>json string url: URL of the document.
383+
:>json object meta: meta data of the requested section.
384+
385+
:query string project: Read the Docs project's slug.
386+
:query string doc: document to fetch content from.
387+
388+
:query string version: *optional* Read the Docs version's slug (default: ``latest``).
389+
:query string section: *optional* section within the document to fetch.
390+
:query string path: *optional* full path to the document including extension.
391+
392+
:query string url: full URL of the document (and section) to fetch content from.
393+
394+
.. note::
395+
396+
You can call this endpoint by sending at least ``project`` and ``doc`` *or* ``url`` attribute.
397+
398+
320399
Undocumented resources and endpoints
321400
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
322401

0 commit comments

Comments
 (0)