Widget embed code
Endpoint GET /widgets/:id/embed-code
Retrieve a widget's embed code.
Path Parameters
Required
id
- The widget's id.
Example Request:
- curl
- Node.js
curl -H "Authorization: Bearer ACCESS_TOKEN" "https://api.commoninja.com/platform/api/v1/widgets/894f5aed-29f5-46c5-9f26-022bfccc5292/embed-code"
const axios = require("axios");
async function getData() {
const response = await axios.get(
"https://api.commoninja.com/platform/api/v1/widgets/894f5aed-29f5-46c5-9f26-022bfccc5292/embed-code",
{
headers: {
Authorization: "Bearer ACCESS_TOKEN",
},
}
);
return response.data;
}
getData();
Example Response:
{
"html": "<div class=\"commonninja_component pid-894f5aed-29f5-46c5-9f26-022bfccc5292\"></div>",
"script": "<script src=\"https://cdn.commoninja.com/sdk/latest/commonninja.js\" defer></script>"
}
Tip
You can use the returned HTML to embed the widget on your platform or website. The script tag should be added to the head of your page, and you only need to add it once.