Basic Connector Example - Fluid Topics - 3.9 - Technical Notes

Develop Connectors with the Fluid Topics API

Product
Fluid Topics
FT_Version
3.9
Category
Technical Notes
language
English
audience
public

The following lines provide a basic example that can be copied and pasted in a Python project.

Modifying the login credentials, the source ID and the tenant URL is all that is required to get a new connector up and running.

from fluidtopics.connector import EditorialType, ExternalDocument, LoginAuthentication, Metadata, RemoteClient, StructuredDocument, Topic


def main():
authentication = LoginAuthentication("root@fluidtopics.com", "change_it")
client = RemoteClient("http://localhost:8080/myPortal", authentication, "external")
client.create_source(name="External", description="External source for my connector")

topic_a = Topic.create(
topic_id="topic-id",
title="I am a topic",
body="<p>Hello World!</p>"
)

topic_b = Topic.create(
topic_id="topic-id-2",
title="I am another topic",
body="<p>Hi Earth!</p>"
)

author = Metadata("author", "John Doe")
version = Metadata("version", "4.2")
category = Metadata("category", "Demo")

doc = StructuredDocument.create(
document_id="document-id",
title="Hello World Book",
toc=[topic_a, topic_a],
locale="en-US",
metadata=[author, version, category],
editorial_type=EditorialType.BOOK
)

external_doc = ExternalDocument.create(
document_id="external-document",
title="Hello Fluid Topics!",
url="https://www.fluidtopics.com",
metadata=[author]
)

client.publish(doc, external_doc, publish_name="Uploaded from Fluid Topics Python API")


if __name__ == "__main__":
main()

This code generates and publishes a structured document with two topics and an external document.