|
| 1 | +<img |
| 2 | + src="https://images.contentstack.io/v3/assets/bltc5a09bf374882538/blt8f67099538d234d7/600a87ac6215cf0f9a18c467/contentstack_icon.svg" /> |
| 3 | +<br> |
| 4 | +<p>Contentstack provides OpenAPI files for its Content Delivery and Content Management REST APIs. These files are in |
| 5 | + JSON format. Using these JSON files, you can automatically generate API documentation, test API, and do a lot more. |
| 6 | +</p> |
| 7 | +<p>This tutorial will walk you through the process of using Contentstack APIs (Content Delivery and Content Management |
| 8 | + APIs) with Swagger.</p><br> |
| 9 | +<h2>Content Delivery API (CDA)</h2> |
| 10 | +<p>Version: 1.0.0 [Download]</p> |
| 11 | +<p>Last Updated: {Date, e.g., Dec 5, 2021}</p> |
| 12 | +<p><strong>Note</strong>: To use the latest version, <a |
| 13 | + href="https://assets.contentstack.io/v3/assets/bltc5a09bf374882538/blt318e89ee28df7712/600a93fc0839e910126d6026/cda-openapi.json?disposition=download">download |
| 14 | + the CDA file</a> on your system. </p> |
| 15 | +<p>To use Contentstack Content Delivery API (CDA) with Swagger, perform the following steps: </p> |
| 16 | +<ol> |
| 17 | + <li><a |
| 18 | + href="https://assets.contentstack.io/v3/assets/bltc5a09bf374882538/blt318e89ee28df7712/600a93fc0839e910126d6026/cda-openapi.json?disposition=download">Download |
| 19 | + the CDA file</a> and go to the <a href="https://editor.swagger.io/">Swagger Editor</a>.</li> |
| 20 | + <li>On the “Swagger Editor” page, click on <strong>File</strong>, and select the <strong>Import file</strong> option. |
| 21 | + </li> |
| 22 | +</ol> |
| 23 | +<p>Alternatively, if you want to use the Import URL option, you can <a |
| 24 | + href="https://www.contentstack.com/docs/content-managers/working-with-assets/create-upload-assets/">upload the CDA |
| 25 | + file as an asset</a> in Contentstack, and then paste the asset’s URL in the prompt.</p> |
| 26 | +<ol> |
| 27 | + <li>Open any API request and click on the <strong>Try it out </strong>button. Clicking this button will unlock the |
| 28 | + fields, so you can either run the API request on our demo stack or can use your own values.</li> |
| 29 | + <li>Click on <strong>Execute</strong>.</li> |
| 30 | +</ol><br> |
| 31 | +<p>In the <strong>Responses </strong>section, you can see the following details:</p> |
| 32 | +<ul> |
| 33 | + <li>API request in CURL format</li> |
| 34 | + <li>Response body</li> |
| 35 | + <li>Status code </li> |
| 36 | +</ul><br> |
| 37 | +<h2>Content Management API</h2> |
| 38 | +<p>Version: 1.0.0 [Download]</p> |
| 39 | +<p>Last Updated: {Date, e.g., Dec 5, 2021}</p> |
| 40 | +<p><strong>Note</strong>: To use the latest version, <a |
| 41 | + href="https://assets.contentstack.io/v3/assets/bltc5a09bf374882538/blt35dc5eaeb2cfc52d/600a93fd4485e50f8f209efe/cma-openapi.json?disposition=download">download |
| 42 | + the CMA file</a> on your system. </p> |
| 43 | +<p>To use Contentstack Content Management API (CMA) with Swagger, perform the following steps: </p> |
| 44 | +<ol> |
| 45 | + <li><a |
| 46 | + href="https://assets.contentstack.io/v3/assets/bltc5a09bf374882538/blt35dc5eaeb2cfc52d/600a93fd4485e50f8f209efe/cma-openapi.json?disposition=download">Download |
| 47 | + the CMA file</a> and go to the <a href="https://editor.swagger.io/">Swagger Editor</a>. </li> |
| 48 | + <li>On the “Swagger Editor” page, click on<strong> File</strong>, and select the <strong>Import file </strong>option. |
| 49 | + </li> |
| 50 | + <li>Alternatively, you can <a |
| 51 | + href="https://www.contentstack.com/docs/content-managers/working-with-assets/create-upload-assets/">upload the CMA |
| 52 | + file as an asset</a> in Contentstack. Then, you can use the <strong>Import URL</strong> option and paste the |
| 53 | + asset’s URL in the prompt. </li> |
| 54 | + <li>To run any API request for CMA, make sure you have either the Management token or Auth token in hand. <ol> |
| 55 | + <li>To use a management token, refer to the Generate Management token guide. </li> |
| 56 | + <li>To use Auth token, run the <strong>Login </strong>API request, located under the <strong>User Session |
| 57 | + </strong>section. </li> |
| 58 | + </ol> |
| 59 | + </li> |
| 60 | + <li>Open any API request and click on the <strong>Try it out</strong> button. Clicking this button will unlock the |
| 61 | + fields for you to use your enter the values. </li> |
| 62 | + <li>Click <strong>Execute</strong>.</li> |
| 63 | +</ol><br> |
| 64 | +<p>In the <strong>Responses </strong>section, you can see the following details:</p> |
| 65 | +<ul> |
| 66 | + <li>API request in CURL format</li> |
| 67 | + <li>Response body</li> |
| 68 | + <li>Status code</li> |
| 69 | +</ul> |
| 70 | +<h2>Points to note:</h2> |
| 71 | +<ul> |
| 72 | + <li>We recommend using the Management token for executing CMA requests rather than Auth token. </li> |
| 73 | + <li>For any DELETE request that has a request body in it, you won’t be able to run it in Swagger. In such scenarios, |
| 74 | + refer to the documentation link provided in the call for more details.</li> |
| 75 | +</ul><br> |
0 commit comments