### Generate Component via cURL Source: https://docs.divmagic.com/api/sample-requests This example shows how to make a POST request to the DivMagic API using cURL to generate a component. It requires an API key, a URL, and optional settings for component and style formats. The request body is sent as JSON. ```sh curl -X POST -H "Content-type: application/json" -d '{"apiKey":"YOUR-API-KEY","url":"pocket.tailwindui.com","settings":{"componentFormat":"html","styleFormat":"tailwind"}}' https://api.divmagic.com/v1/magic ``` -------------------------------- ### Generate Component via JavaScript Source: https://docs.divmagic.com/api/sample-requests This example demonstrates how to use the JavaScript fetch API to send a POST request to the DivMagic API. It includes the necessary headers and a JSON body containing the API key, URL, and formatting settings. The response is then logged to the console. ```javascript fetch('https://api.divmagic.com/v1/magic', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ 'apiKey': 'YOUR_API_KEY', 'url': 'ft.com', 'settings': { 'componentFormat': 'html', 'styleFormat': 'tailwind' } }) }) .then(response => response.json()) .then(data => console.log(data)); ``` -------------------------------- ### Website Project Configuration Source: https://docs.divmagic.com/api/request-parameters This section details the request parameters available when configuring website projects within Divmagic. ```APIDOC ## Website Project Configuration API ### Description This API allows you to configure various aspects of your website projects, including component format, style format, and media query inclusion. ### Method GET (Implied, as parameters are described for requests) ### Endpoint /websites/divmagic ### Parameters #### Query Parameters - **componentFormat** (string) - Optional - Specifies the desired format for components. Supported values: "html", "jsx". - **styleFormat** (string) - Optional - Specifies the desired format for styles. Supported values: "tailwind", "inline", "local", "external". - **includeMediaQuery** (boolean) - Optional - Determines whether to include media query settings. Supported values: true, false. ### Request Example ```json { "componentFormat": "jsx", "styleFormat": "tailwind", "includeMediaQuery": true } ``` ### Response #### Success Response (200) This endpoint does not explicitly define a success response body in the provided text. It primarily describes request parameters. #### Response Example (No specific response example provided in the input text.) ``` -------------------------------- ### POST /v1/magic Source: https://docs.divmagic.com/api/sample-requests This endpoint allows you to generate code components by providing a URL and desired settings. It accepts an API key for authentication. ```APIDOC ## POST /v1/magic ### Description This endpoint generates code components from a given URL. You need to provide an API key and specify settings for the output format. ### Method POST ### Endpoint https://api.divmagic.com/v1/magic ### Parameters #### Request Body - **apiKey** (string) - Required - Your Divmagic API key. - **url** (string) - Required - The URL from which to generate components. - **settings** (object) - Optional - Settings for component generation. - **componentFormat** (string) - Optional - The desired format for the component (e.g., 'html'). - **styleFormat** (string) - Optional - The desired style format (e.g., 'tailwind'). ### Request Example ```json { "apiKey": "YOUR-API-KEY", "url": "pocket.tailwindui.com", "settings": { "componentFormat": "html", "styleFormat": "tailwind" } } ``` ### Response #### Success Response (200) - **data** (object) - Contains the generated component data. - **html** (string) - The generated HTML component. - **tailwind** (string) - The generated Tailwind CSS. #### Response Example ```json { "data": { "html": "
...
", "tailwind": ".class { ... }" } } ``` ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.