Export CSV Files from API Calls - HL Vanilla Community
<main> <article class="userContent"> <p>You can export data (such as <em>user records</em> and <em>your most recent discussions</em>) to a CSV file from the API. In theory, doing so is as simple as adding <strong>.csv</strong> to the end of an API call but, in practice, it will require a bit of extra work to make it as useful as possible.</p><p>⭐️ <strong>EXAMPLE</strong>: Below is an example using the <strong>GET /users</strong> API call:</p><p><code class="code codeInline" spellcheck="false" tabindex="0">{<em>your_site_URL</em>}/api/v2/users.csv</code></p><p><em>By default</em>, this will return one page of only 30 user records.</p><p>However, the <strong>GET /users</strong> API call can return <strong>up to 5,000 user records</strong> at a time, but you have to add the <strong><code class="code codeInline" spellcheck="false" tabindex="0">page</code></strong> and <strong><code class="code codeInline" spellcheck="false" tabindex="0">limit</code></strong> parameters, as shown:</p><p><code class="code codeInline" spellcheck="false" tabindex="0">{<em>your_site_URL</em>}/api/v2/users.csv?<strong>page=1&limit=5000</strong></code></p><p>📝 <strong>NOTE</strong>: The 5,000 record limit is only available when exporting to CSV. If you are making a standard API call, the limit is 500 users.</p><p>To get the next 5,000 user records, just increase the value of the <strong><code class="code codeInline" spellcheck="false" tabindex="0">page</code></strong> parameter, specifying the next page number:</p><p><code class="code codeInline" spellcheck="false" tabindex="0">{<em>your_site_URL</em>}/api/v2/users.csv?<strong>page=2</strong>&limit=5000</code></p><p>✔️ <strong>TIP</strong>: Building on this example, if you have 50,000 users, you'll have to repeat this process up through <strong><code class="code codeInline" spellcheck="false" tabindex="0">page=10</code></strong> to get all your user records.</p><p>Essentially, the default values, <strong>page=1</strong> and <strong>limit=30</strong>, are assumed but can be increased and additional parameters can be used in order to export specific data as described below.</p><h2 data-id="other-useful-parameters">Other useful parameters</h2><p>There are other parameters that make the <strong>GET /users</strong> API call even more useful.</p><h3 data-id="date-focused">Date focused</h3><p>⭐️ <strong>EXAMPLE</strong>: Get a list of all new members who have <em>joined on and after a specified date</em> by including the <strong><code class="code codeInline" spellcheck="false" tabindex="0">dateInserted</code></strong> parameter:</p><p><code class="code codeInline" spellcheck="false" tabindex="0">{<em>your_site_URL</em>}/api/v2/users.csv?<strong>dateInserted=>=2022-10-03</strong>&page=1&limit=5000</code></p><h4 data-id="specifying-dates">Specifying dates</h4><p>You can export date-based data in several ways by specifying the <strong><code class="code codeInline" spellcheck="false" tabindex="0">dateInserted</code></strong> parameter with some standard mathematical operators (<strong>=</strong>, <strong>>=</strong>, <strong>></strong>, <strong><=</strong>, <strong><</strong>) , as in:</p><ul><li><code class="code codeInline" spellcheck="false" tabindex="0">dateInserted<strong>=</strong>2022-10-03</code> means "on this date only"</li><li><code class="code codeInline" spellcheck="false" tabindex="0">dateInserted=>2022-10-03</code> means "all days after (<em>but not including</em>) this date"</li><li><code class="code codeInline" spellcheck="false" tabindex="0">dateInserted<strong>=>=</strong>2022-10-03</code> means "on this date and after"</li></ul><h3 data-id="user-data">User data</h3><p>⭐️ <strong>EXAMPLE</strong>: Get all available user data and have it expand all the records in the CSV file by adding the <strong><code class="code codeInline" spellcheck="false" tabindex="0">expand</code></strong> parameter:</p><p><code class="code codeInline" spellcheck="false" tabindex="0">{<em>your_site_URL</em>}/api/v2/users.csv?page=1&limit=5000&<strong>expand=all</strong></code></p><p>⭐️ <strong>EXAMPLE</strong>: You ca also use the <strong><code class="code codeInline" spellcheck="false" tabindex="0">expand</code></strong> parameter to include the extended profile fields:</p><p><code class="code codeInline" spellcheck="false" tabindex="0">{<em>your_site_URL</em>}/api/v2/users.csv?page=1&limit=5000&<strong>expand=extended</strong></code></p><h2 data-id="additional-resources">Additional resources</h2><p>To learn about (and try out!) the options that are available with the <strong>/users</strong> endpoint and our other endpoints, check out the <strong>API v2</strong> page in your Vanilla dashboard (<strong>Settings > API Integrations > API v2</strong>).</p><ul><li>To see a current list of all of Vanilla's API v2 endpoints, see:</li></ul><div class="js-embed embedResponsive" data-embedjson="{"body":"This document is an up-to-date API reference for all of Vanilla's public APIv2 endpoints.","photoUrl":"https:\/\/us.v-cdn.net\/6030677\/uploads\/GXW21TRYG1JP\/share-imagevanilla-community.jpg","url":"https:\/\/success.vanillaforums.com\/kb\/articles\/202","embedType":"link","name":"API v2 Reference & Endpoints - HL Vanilla Community"}"> <a href="https://success.vanillaforums.com/kb/articles/202" rel="nofollow noreferrer ugc"> https://success.vanillaforums.com/kb/articles/202 </a> </div><p><br></p> </article> </main>