The window.fluidtopics.FluidTopicsApi() method allows designers to use the Fluid Topics API in Custom components more easily.
The following example uses the GET HTTP method to call the List bookmarks web service for the current user. It then prints its response in the browser console:
FTAPI = await new window.fluidtopics.FluidTopicsApi();
FTAPI["ftCallingApp"] = "custom-component-XXX"; // Change XXX to a more descriptive name
bookmarks = await FTAPI.get(`/api/users/${user.profile.id}/bookmarks`);
console.log(bookmarks);
The following example uses the POST HTTP method to call the Search maps web service, asking for maps matching the word "API" and in American English. It then prints its response in the browser console:
FTAPI = await new window.fluidtopics.FluidTopicsApi();
FTAPI["ftCallingApp"] = "custom-component-XXX"; // Change XXX to a more descriptive name
body = {
"query": "API",
"contentLocale": "en-US"
}
api_maps = await FTAPI.post(`/api/khub/maps/search`, body);
console.log(api_maps);
See User bookmarks example for a use case featuring the API access method.
Custom components that call the Fluid Topics API must include an ftCallingApp header. To exclude these API calls from billing, set the ftCallingApp value to a name starting with custom-component.
- The code for Custom components is public. Do not add credentials in a Custom component.
- Fluid Topics user roles limit the web services which a user can call. For more information, see the Fluid Topics API Reference Guide.