curl --request POST \
--url 'https://api.widgetic.com/embed/compositions/123e4567-e89b-12d3-a456-426614174000/adapters/example/example' \
--header 'Content-Type: application/json' \
--data '{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}'import { Configuration, PublicEmbedApi } from '@widgetic/api-sdk-ts';
const publicEmbedApi = new PublicEmbedApi(new Configuration({ basePath: 'https://api.widgetic.com' }));
const result = await publicEmbedApi.callPublicCompositionAdapter({
compositionId: '123e4567-e89b-12d3-a456-426614174000',
adapterId: 'example',
operation: 'example',
publicAdapterCallRequest: {
requestId: 'example-key',
version: 42,
input: {},
context: {},
},
});
console.log(result);import api_sdk_py
configuration = api_sdk_py.Configuration(host="https://api.widgetic.com")
with api_sdk_py.ApiClient(configuration) as api_client:
public_embed_api = api_sdk_py.PublicEmbedApi(api_client)
result = public_embed_api.call_public_composition_adapter(
composition_id="123e4567-e89b-12d3-a456-426614174000",
adapter_id="example",
operation="example",
public_adapter_call_request={
"requestId": "example-key",
"version": 42,
"input": {},
"context": {},
},
)
print(result)package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
widgetic "github.com/widgetic/api-sdk-go"
)
func main() {
ctx := context.Background()
configuration := widgetic.NewConfiguration()
configuration.Servers = widgetic.ServerConfigurations{{URL: "https://api.widgetic.com"}}
client := widgetic.NewAPIClient(configuration)
publicAdapterCallRequestJSON := `{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}`
var publicAdapterCallRequest widgetic.PublicAdapterCallRequest
if err := json.Unmarshal([]byte(publicAdapterCallRequestJSON), &publicAdapterCallRequest); err != nil {
log.Fatal(err)
}
result, _, err := client.PublicEmbedAPI.CallPublicCompositionAdapter(ctx, "123e4567-e89b-12d3-a456-426614174000", "example", "example").
PublicAdapterCallRequest(publicAdapterCallRequest).
Execute()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println(result)
}import com.widgetic.api.ApiClient;
import com.widgetic.api.ApiException;
import com.widgetic.api.Configuration;
import com.widgetic.api.JSON;
import com.widgetic.api.api.PublicEmbedApi;
import com.widgetic.api.model.PublicAdapterCallRequest;
import java.util.UUID;
public class Example {
public static void main(String[] args) throws ApiException {
ApiClient client = Configuration.getDefaultApiClient();
client.setBasePath("https://api.widgetic.com");
PublicEmbedApi publicEmbedApi = new PublicEmbedApi(client);
String publicAdapterCallRequestJson = """
{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}
""";
PublicAdapterCallRequest publicAdapterCallRequest = JSON.deserialize(publicAdapterCallRequestJson, PublicAdapterCallRequest.class);
var result = publicEmbedApi.callPublicCompositionAdapter(
UUID.fromString("123e4567-e89b-12d3-a456-426614174000"),
"example",
"example",
publicAdapterCallRequest
);
System.out.println(result);
}
}using System;
using Newtonsoft.Json;
using Widgetic.ApiSdk.Cs.Api;
using Widgetic.ApiSdk.Cs.Client;
using Widgetic.ApiSdk.Cs.Model;
var configuration = new Configuration
{
BasePath = "https://api.widgetic.com",
};
var publicEmbedApi = new PublicEmbedApi(configuration);
var publicAdapterCallRequest = JsonConvert.DeserializeObject<PublicAdapterCallRequest>("""
{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}
""")!;
var result = publicEmbedApi.CallPublicCompositionAdapter(
compositionId: Guid.Parse("123e4567-e89b-12d3-a456-426614174000"),
adapterId: "example",
operation: "example",
publicAdapterCallRequest: publicAdapterCallRequest
);
Console.WriteLine(result);require 'api-sdk-rb'
ApiSdkRb.configure do |config|
config.host = 'api.widgetic.com'
config.base_path = ''
end
public_embed_api = ApiSdkRb::PublicEmbedApi.new
result = public_embed_api.call_public_composition_adapter(
'123e4567-e89b-12d3-a456-426614174000',
'example',
'example',
{
requestId: 'example-key',
version: 42,
input: {},
context: {}
}
)
puts result<?php
require_once __DIR__ . '/vendor/autoload.php';
use WidgeticApi\Api\PublicEmbedApi;
use WidgeticApi\Configuration;
use WidgeticApi\Model\PublicAdapterCallRequest;
use WidgeticApi\ObjectSerializer;
$config = Configuration::getDefaultConfiguration()->setHost('https://api.widgetic.com');
$publicEmbedApi = new PublicEmbedApi(new GuzzleHttp\Client(), $config);
$publicAdapterCallRequestJson = '{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}';
$publicAdapterCallRequest = ObjectSerializer::deserialize(json_decode($publicAdapterCallRequestJson), PublicAdapterCallRequest::class);
$result = $publicEmbedApi->callPublicCompositionAdapter(
composition_id: '123e4567-e89b-12d3-a456-426614174000',
adapter_id: 'example',
operation: 'example',
public_adapter_call_request: $publicAdapterCallRequest,
);
print_r($result);{
"success": true,
"data": {}
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": true,
"message": "Example message",
"code": "NOT_FOUND",
"details": {},
"correlationId": "Example correlationId",
"error": {}
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}Call an adapter
The door a widget’s adapter module calls, from the visitor’s browser, for the operations that cannot run in the browser: anything with a secret, a charge in credits or the owner’s storage behind it. A widget that uses such an adapter is handed the address of this route as adapters.url in its widgetic:host message (see the host bridge contract) and calls {adapters.url}/{adapterId}/{operation}. It is not meant to be called by hand, and it takes no API key.
Address. https://api.widgetic.com/embed/compositions/{compositionId}/adapters/{adapterId}/{operation}: the root of the API host, NOT under /v1. A client generated from this description for https://api.widgetic.com/v1 must be given the base address https://api.widgetic.com for the calls of the Public Embed tag.
What it serves. Only an adapter, and a version of it, that the widget’s LIVE manifest (what the version that is published uses) lists, and only an operation that runs on the gateway. Anything else is one 404 ADAPTER_NOT_AVAILABLE, whatever the reason, so the route is no way to ask what a widget contains. An adapter an administrator stopped offering to NEW widgets keeps serving the widgets that already use it.
Who may call. The same rule as the entry route: a permitted Origin header, which is the artifact origin the widget runs from or any website when the owner has not restricted the allowed websites (when the owner has, one of the websites the owner listed, Widgetic’s own sites, the visitor’s own machine or the owner’s own platform). Page script cannot forge it. A request without a permitted Origin is 403 ORIGIN_NOT_ALLOWED. A composition that is not served (unpublished, or its owner’s plan does not serve it) is 404, with the codes of the other public embed routes. When the partner of the owner signs the host context, a context that is not signed as the partner requires is refused with 403 CONTEXT_SIGNATURE_REQUIRED, CONTEXT_SIGNATURE_INVALID or CONTEXT_SIGNATURE_EXPIRED.
Cost and retries. An operation priced in credits is charged to the owner of the widget (for a customer a partner manages, to the partner’s administrator, within the monthly credits set for that customer), once for each requestId, before it runs, and given back if it does not answer. A requestId that was charged and not given back is 409 REQUEST_ALREADY_USED and the operation is NOT run a second time; one whose charge was given back may be tried again with the same requestId. A visitor never sees an owner’s balance: a feature that cannot be used because its owner has no credits left, because the customer’s monthly credits are spent, or because an administrator stopped the adapter, is the same 503 ADAPTER_UNAVAILABLE as every other “not right now”. The owner is told through a notice.
Limits. In front of everything, 120 calls a minute for each visitor address and composition and 600 a minute for a composition (429 RATE_LIMITED). Then, for each operation of a widget, a rate for each visitor address a minute and a cap for the widget a day: 30 and 5000 for an operation that is free, 10 and 500 for one that costs credits, unless the adapter says otherwise (never above 120 and 100000). A visitor over the rate is 429 RATE_LIMITED; a widget over its cap is 429 WIDGET_LIMIT_REACHED. Both carry a Retry-After header. The body is at most 64 KiB (413 PAYLOAD_TOO_LARGE) and JSON (415 UNSUPPORTED_MEDIA_TYPE); an operation has 30 seconds to answer (504 ADAPTER_TIMEOUT, and the charge is given back).
curl --request POST \
--url 'https://api.widgetic.com/embed/compositions/123e4567-e89b-12d3-a456-426614174000/adapters/example/example' \
--header 'Content-Type: application/json' \
--data '{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}'import { Configuration, PublicEmbedApi } from '@widgetic/api-sdk-ts';
const publicEmbedApi = new PublicEmbedApi(new Configuration({ basePath: 'https://api.widgetic.com' }));
const result = await publicEmbedApi.callPublicCompositionAdapter({
compositionId: '123e4567-e89b-12d3-a456-426614174000',
adapterId: 'example',
operation: 'example',
publicAdapterCallRequest: {
requestId: 'example-key',
version: 42,
input: {},
context: {},
},
});
console.log(result);import api_sdk_py
configuration = api_sdk_py.Configuration(host="https://api.widgetic.com")
with api_sdk_py.ApiClient(configuration) as api_client:
public_embed_api = api_sdk_py.PublicEmbedApi(api_client)
result = public_embed_api.call_public_composition_adapter(
composition_id="123e4567-e89b-12d3-a456-426614174000",
adapter_id="example",
operation="example",
public_adapter_call_request={
"requestId": "example-key",
"version": 42,
"input": {},
"context": {},
},
)
print(result)package main
import (
"context"
"encoding/json"
"fmt"
"log"
"os"
widgetic "github.com/widgetic/api-sdk-go"
)
func main() {
ctx := context.Background()
configuration := widgetic.NewConfiguration()
configuration.Servers = widgetic.ServerConfigurations{{URL: "https://api.widgetic.com"}}
client := widgetic.NewAPIClient(configuration)
publicAdapterCallRequestJSON := `{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}`
var publicAdapterCallRequest widgetic.PublicAdapterCallRequest
if err := json.Unmarshal([]byte(publicAdapterCallRequestJSON), &publicAdapterCallRequest); err != nil {
log.Fatal(err)
}
result, _, err := client.PublicEmbedAPI.CallPublicCompositionAdapter(ctx, "123e4567-e89b-12d3-a456-426614174000", "example", "example").
PublicAdapterCallRequest(publicAdapterCallRequest).
Execute()
if err != nil {
fmt.Fprintln(os.Stderr, err)
os.Exit(1)
}
fmt.Println(result)
}import com.widgetic.api.ApiClient;
import com.widgetic.api.ApiException;
import com.widgetic.api.Configuration;
import com.widgetic.api.JSON;
import com.widgetic.api.api.PublicEmbedApi;
import com.widgetic.api.model.PublicAdapterCallRequest;
import java.util.UUID;
public class Example {
public static void main(String[] args) throws ApiException {
ApiClient client = Configuration.getDefaultApiClient();
client.setBasePath("https://api.widgetic.com");
PublicEmbedApi publicEmbedApi = new PublicEmbedApi(client);
String publicAdapterCallRequestJson = """
{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}
""";
PublicAdapterCallRequest publicAdapterCallRequest = JSON.deserialize(publicAdapterCallRequestJson, PublicAdapterCallRequest.class);
var result = publicEmbedApi.callPublicCompositionAdapter(
UUID.fromString("123e4567-e89b-12d3-a456-426614174000"),
"example",
"example",
publicAdapterCallRequest
);
System.out.println(result);
}
}using System;
using Newtonsoft.Json;
using Widgetic.ApiSdk.Cs.Api;
using Widgetic.ApiSdk.Cs.Client;
using Widgetic.ApiSdk.Cs.Model;
var configuration = new Configuration
{
BasePath = "https://api.widgetic.com",
};
var publicEmbedApi = new PublicEmbedApi(configuration);
var publicAdapterCallRequest = JsonConvert.DeserializeObject<PublicAdapterCallRequest>("""
{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}
""")!;
var result = publicEmbedApi.CallPublicCompositionAdapter(
compositionId: Guid.Parse("123e4567-e89b-12d3-a456-426614174000"),
adapterId: "example",
operation: "example",
publicAdapterCallRequest: publicAdapterCallRequest
);
Console.WriteLine(result);require 'api-sdk-rb'
ApiSdkRb.configure do |config|
config.host = 'api.widgetic.com'
config.base_path = ''
end
public_embed_api = ApiSdkRb::PublicEmbedApi.new
result = public_embed_api.call_public_composition_adapter(
'123e4567-e89b-12d3-a456-426614174000',
'example',
'example',
{
requestId: 'example-key',
version: 42,
input: {},
context: {}
}
)
puts result<?php
require_once __DIR__ . '/vendor/autoload.php';
use WidgeticApi\Api\PublicEmbedApi;
use WidgeticApi\Configuration;
use WidgeticApi\Model\PublicAdapterCallRequest;
use WidgeticApi\ObjectSerializer;
$config = Configuration::getDefaultConfiguration()->setHost('https://api.widgetic.com');
$publicEmbedApi = new PublicEmbedApi(new GuzzleHttp\Client(), $config);
$publicAdapterCallRequestJson = '{
"requestId": "example-key",
"version": 42,
"input": {},
"context": {}
}';
$publicAdapterCallRequest = ObjectSerializer::deserialize(json_decode($publicAdapterCallRequestJson), PublicAdapterCallRequest::class);
$result = $publicEmbedApi->callPublicCompositionAdapter(
composition_id: '123e4567-e89b-12d3-a456-426614174000',
adapter_id: 'example',
operation: 'example',
public_adapter_call_request: $publicAdapterCallRequest,
);
print_r($result);{
"success": true,
"data": {}
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": true,
"message": "Example message",
"code": "NOT_FOUND",
"details": {},
"correlationId": "Example correlationId",
"error": {}
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}{
"success": false,
"error": "Example error",
"code": "Example code",
"correlationId": "Example correlationId"
}Path Parameters
Body
Names this attempt: 8 to 64 characters, letters, digits, _ and -, the first a letter or a digit (a UUID fits). A module makes a new one for each action of the visitor. An operation that costs credits is charged once for each requestId, so a repeat of one that was charged and not given back is refused (409 REQUEST_ALREADY_USED) and does no work.
^[A-Za-z0-9][A-Za-z0-9_-]{7,63}$