{"id":691,"date":"2017-04-21T15:25:02","date_gmt":"2017-04-21T15:25:02","guid":{"rendered":"http:\/\/live.ecd-demo.com\/apihelp\/?page_id=691"},"modified":"2025-07-21T17:39:09","modified_gmt":"2025-07-21T17:39:09","slug":"source-documents","status":"publish","type":"page","link":"https:\/\/apihelp.ecd-demo.com\/index.php\/documentation\/source-documents\/","title":{"rendered":"Source documents"},"content":{"rendered":"<h3>Source store and documents<\/h3>\n<p>The URL below show GET request to retrieve the first 100 <em>source<\/em> documents from the <em>source<\/em> store.<\/p>\n<pre><code class=\"swift\">GET https:\/\/&lt;base-url&gt;\/stores-active\/source\/filter?offset=0&amp;limit=100&amp;api_key=&lt;api-key&gt;\n<\/code><\/pre>\n<table>\n<thead>\n<tr>\n<th>Paramenter<\/th>\n<th>description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>offset=0<\/td>\n<td>instructs the API to skip zero document in the store<\/td>\n<\/tr>\n<tr>\n<td>limit=100<\/td>\n<td>instructs the API to return 100 documents<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote><p>For more details and options try this in the <a href=\"https:\/\/apihelp.ecd-demo.com\/index.php\/api-explorer\/\">API explorer<\/a><\/p><\/blockquote>\n<p>This is the basis of pagination. By systematically adjusting the &#8220;offset&#8221; and &#8220;limit&#8221; query parameters, we can download the documents in a store &#8220;n&#8221; number of items at a time until all documents in the store are downloaded.<\/p>\n<h4>GET source documents in chunks<\/h4>\n<p>So, if we want to retrieve all source documents but only 100 source documents at a time, we would submit the request above in a loop while adjusting the parameter values in each iteration like in the pseudocode below:<\/p>\n<pre><code class=\"swift\">var curr_offset = 0, doc_count = 100;\nvar response = https:\/\/&lt;base-url&gt;\/stores-active\/source\/filter?offset={curr_offset}&amp;limit={doc_count};\nwhile (status code of response is 200) {\n        curr_offset = curr_offset + doc_count;\n        response = https:\/\/&lt;base-url&gt;\/stores-active\/source\/filter?offset={curr_offset}&amp;limit={doc_count};\n        \/* process response here *\/\n}\n<\/code><\/pre>\n<p>Or recursively like below:<\/p>\n<pre><code class=\"swift\"> function GetData(curr_offset, doc_count) {\n            var response = https:\/\/&lt;base-url&gt;\/stores-active\/source\/filter?offset={curr_offset}&amp;limit={doc_count};\n            if (status code of response is 200) {\n                    \/* process response here *\/\n                    GetData(curr_offset+doc_count, doc_count);\n            } else {\n                    return;\n            }\n    }\n<\/code><\/pre>\n<p><em>Currently a value of 10,000 is the maximum allowed value for the parameter <code>limit<\/code> due to on the backend system requirements.<\/em><\/p>\n<p>Now that we know how to paginate and use the request to retrieve all documents in the source store in chunks, we can apply the same tehnique to retrieve other types of documents from other stores as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Source store and documents The URL below show GET request to retrieve the first 100 source documents from the source store. GET https:\/\/&lt;base-url&gt;\/stores-active\/source\/filter?offset=0&amp;limit=100&amp;api_key=&lt;api-key&gt; Paramenter description offset=0 instructs the API to skip zero document in the store limit=100 instructs the API to return 100 documents For more details and options try this in the API explorer [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"parent":279,"menu_order":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"footnotes":""},"class_list":["post-691","page","type-page","status-publish","hentry"],"_links":{"self":[{"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages\/691","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages"}],"about":[{"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/types\/page"}],"author":[{"embeddable":true,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/comments?post=691"}],"version-history":[{"count":2,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages\/691\/revisions"}],"predecessor-version":[{"id":1515,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages\/691\/revisions\/1515"}],"up":[{"embeddable":true,"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/pages\/279"}],"wp:attachment":[{"href":"https:\/\/apihelp.ecd-demo.com\/index.php\/wp-json\/wp\/v2\/media?parent=691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}