FastComments.com

Die FastComments API

FastComments stellt eine API zur Verfügung, um mit vielen Ressourcen zu interagieren. Erstellen Sie Integrationen mit unserer Plattform oder bauen Sie sogar Ihre eigenen Clients!

In dieser Dokumentation finden Sie alle vom API unterstützten Ressourcen, dokumentiert mit ihren Anfrage- und Antworttypen.

Für Enterprise-Kunden wird sämtlicher API-Zugriff im Audit-Log protokolliert.

Generierte SDKs

FastComments erzeugt jetzt eine API-Spezifikation aus unserem Code (dies ist noch nicht vollständig, enthält aber viele APIs).

Wir haben jetzt auch SDKs für beliebte Sprachen:

Authentifizierung

Die API wird authentifiziert, indem Sie Ihren api key entweder als X-API-KEY Header oder als API_KEY Query-Parameter übergeben. Sie benötigen außerdem Ihre tenantId für API-Aufrufe. Diese kann auf derselben Seite wie Ihr api key abgerufen werden.

Sicherheitshinweis

Diese Routen sind dafür gedacht, von einem Server aufgerufen zu werden. RUFEN SIE SIE NICHT aus einem Browser auf. Wenn Sie dies tun, wird Ihr API-Schlüssel offengelegt - dadurch erhält jede Person, die den Quellcode einer Seite einsehen kann, vollen Zugriff auf Ihr Konto!

Authentifizierungsoption Eins - Header

  • Header: X-API-KEY
  • Header: X-TENANT-ID

Authentifizierungsoption Zwei - Query-Parameter

  • Query-Parameter: API_KEY
  • Query-Parameter: tenantId

Audit-Log-Struktur Internal Link

Ein AuditLog ist ein Objekt, das ein auditiertes Ereignis für Tenants darstellt, die Zugriff auf diese Funktion haben.

Die Struktur für das AuditLog-Objekt ist wie folgt:

AuditLog Struktur
Copy Copy
1
2interface AuditLog {
3 id: string;
4 userId?: string;
5 username?: string;
6 resourceName: string;
7 crudType: 'c' | 'r' | 'u' | 'd' | 'login';
8 from: string;
9 url?: string;
10 ip?: string;
11 when: string;
12 description?: string;
13 serverStartDate: string;
14 objectDetails?: object;
15}
16

Das Audit-Log ist unveränderlich. Es kann auch nicht manuell beschrieben werden. Nur FastComments.com entscheidet, wann ins Audit-Log geschrieben wird. Sie können es jedoch über diese API lesen.

Ereignisse im Audit-Log verfallen nach zwei Jahren.

Kommentarstruktur Internal Link

Ein Comment-Objekt repräsentiert einen Kommentar, der von einem Benutzer hinterlassen wurde.

Die Beziehung zwischen übergeordneten und untergeordneten Kommentaren wird über parentId definiert.

Die Struktur für das Comment-Objekt ist wie folgt:

Comment Struktur
Copy Copy
1
2interface Comment {
3 /** READONLY: Set to true if the spam engine determined the comment was spam. **/
4 aiDeterminedSpam?: boolean
5 /** Whether the comment is approved to show. Set to true when saving the comment, else it will be hidden. **/
6 approved?: boolean
7 /** The user's avatar. **/
8 avatarSrc?: string
9 /** Child comments. Not populated in all scenarios. Used when asTree is set to true via the API. **/
10 children: Comment[]
11 /** The commenter's raw comment. **/
12 comment: string
13 /** READONLY: The commenter's comment parsed into HTML. **/
14 commentHTML?: string
15 /** The commenter's email. Required if anonymous commenting is off. **/
16 commenterEmail?: string
17 /** The commenter's link (for example, their blog). **/
18 commenterLink?: string
19 /** The commenter's name. Always required. If not available, set to something like "Anonymous". **/
20 commenterName: string
21 /** The date the comment was left, in UTC epoch. **/
22 date: number
23 /** The "display label" for the comment - for example "Admin", "Moderator", or something like "VIP User". **/
24 displayLabel?: string
25 /** The domain the comment was posted on. **/
26 domain?: string
27 /** READONLY: The number of times the comment was flagged. **/
28 flagCount?: number
29 /** The #hashtags written in the comment that were successfully parsed. You can also manually add hashtags, for querying, but they won't display in the comment text automatically. **/
30 hashTags?: CommentHashTag[]
31 /** READONLY: Does the comment contain images? **/
32 hasImages?: boolean
33 /** READONLY: Does the comment contain links? **/
34 hasLinks?: boolean
35 /** READONLY: The unique comment id. **/
36 id: string
37 /** Only on create! This is hashed for storage. **/
38 ip?: string
39 /** READONLY: Did the current user block the user that wrote this comment? **/
40 isBlocked?: boolean
41 /** READONLY: Is the comment by an admin? Automatically set based on userId. **/
42 isByAdmin?: boolean
43 /** READONLY: Is the comment by a moderator? Automatically set based on userId. **/
44 isByModerator?: boolean
45 /** Set to true if the comment was soft deleted (placeholder had to be left due to some other configuration). **/
46 isDeleted?: boolean
47 /** Set to true if the user's account was deleted and the comment had to be retained. **/
48 isDeletedUser?: boolean
49 /** READONLY: Is the flagged by the currently logged-in user (contextUserId)? **/
50 isFlagged?: boolean
51 /** Is the comment pinned? **/
52 isPinned?: boolean
53 /** Is the comment locked for new replies (moderators still can reply)? **/
54 isLocked?: boolean
55 /** Is the comment spam? **/
56 isSpam?: boolean
57 /** READONLY: Is the comment voted down for the current user (contextUserId)? **/
58 isVotedDown?: boolean
59 /** READONLY: Is the comment voted up for the current user (contextUserId)? **/
60 isVotedUp?: boolean
61 /** The locale the comment is in. If not provided, will be derived from the language accept HTTP header. **/
62 locale?: 'de_de' | 'en_us' | 'es_es' | 'fr_fr' | 'it_it' | 'ja_jp' | 'ko_kr' | 'pl_pl' | 'pt_br' | 'ru_ru' | 'tr_tr' | 'zh_cn' | 'zh_tw'
63 /** READONLY: The @mentions written in the comment that were successfully parsed. **/
64 mentions?: CommentUserMention[]
65 /** Optional metadata associated with the comment. **/
66 meta?: Record<string, string | number | boolean>
67 /** The optional list of moderation group ids associated with this comment. **/
68 moderationGroupIds?: string[]|null
69 /** READONLY: The id of the vote object that corresponds to the vote from the current user (contextUserId) on this comment. **/
70 myVoteId?: string
71 /** Whether notifications were sent for this comment for commenters. To prevent notifications being sent on imports, set this to true. **/
72 notificationSentForParent?: boolean
73 /** Whether notifications were sent for this comment for tenant users. To prevent notifications being sent on imports, set this to true. **/
74 notificationSentForParentTenant?: boolean
75 /** The title of the page this comment was on. **/
76 pageTitle?: string
77 /** If we're replying to a comment, this is the ID that we are replying to. **/
78 parentId?: string|null
79 /** Whether the comment is marked reviewed. **/
80 reviewed: boolean
81 /** The tenant id where the comment belongs. **/
82 tenantId: string
83 /** The user that wrote the comment. Created automatically when saving a comment with a name/email. **/
84 userId?: string|null
85 /** The URL to the location that this comment is visible, like a blog post. **/
86 url: string
87 /** A "cleaned" version of the urlId you passed us. When saving, you specify this field, but when you fetch the comment back this will be "cleaned" and your original value moved to "urlIdRaw". **/
88 urlId: string
89 /** READONLY: The original urlId you passed us. **/
90 urlIdRaw?: string
91 /** Is the user and this comment verified? **/
92 verified: boolean
93 /** Number of votes up. **/
94 votesUp?: number
95 /** Number of votes down. **/
96 votesDown?: number
97 /** The "karma" of the comment (= votes up - votes down). **/
98 votes?: number
99}
100

Einige dieser Felder sind mit READONLY markiert - diese werden von der API zurückgegeben, können aber nicht gesetzt werden.

Kommentartext-Struktur

Kommentare werden in einem FastComments-Dialekt von Markdown geschrieben, was einfach Markdown plus traditionelle bbcode-Style-Tags für Bilder ist, wie [img]pfad[/img].

Text wird in zwei Feldern gespeichert. Der vom Benutzer eingegebene Text wird unverändert im comment-Feld gespeichert. Dieser wird gerendert und im commentHTML-Feld gespeichert.

Die erlaubten HTML-Tags sind b, u, i, strike, pre, span, code, img, a, strong, ul, ol, li, und br.

Es wird empfohlen, das HTML zu rendern, da es sich um eine sehr kleine Teilmenge von HTML handelt und der Bau eines Renderers ziemlich einfach ist. Es gibt mehrere Bibliotheken für React Native und Flutter, die dabei helfen können.

Sie können auch den nicht normalisierten Wert des comment-Feldes rendern. Ein Beispiel-Parser ist hier..

Der Beispiel-Parser könnte auch angepasst werden, um mit HTML zu arbeiten und die HTML-Tags in erwartete Elemente für Ihre Plattform zu transformieren.

Tagging

Wenn Benutzer in einem Kommentar markiert werden, werden die Informationen in einer Liste namens mentions gespeichert. Jedes Objekt in dieser Liste hat die folgende Struktur.

Das Comment Mentions Objekt
Copy CopyRun External Link
1
2interface CommentUserMention {
3 /** The user id. For SSO users, this will have your tenant id prefixed. **/
4 id: string
5 /** The final @mention tag text, including the @ symbol. **/
6 tag: string
7 /** The original @mention tag text, including the @ symbol. **/
8 rawTag: string
9 /** What type of user was tagged. user = FastComments.com account. sso = SSOUser. **/
10 type: 'user'|'sso'
11 /** If the user opts out of notifications, this will still be set to true. **/
12 sent: boolean
13}
14

HashTags

Wenn Hashtags verwendet und erfolgreich geparst werden, werden die Informationen in einer Liste namens hashTags gespeichert. Jedes Objekt in dieser Liste hat die folgende Struktur. Hashtags können auch manuell zum hashTags-Array des Kommentars für Abfragen hinzugefügt werden, wenn retain gesetzt ist.

Das Comment HashTag Objekt
Copy CopyRun External Link
1
2interface CommentHashTag {
3 /** The hashtag id. **/
4 id: string
5 /** The final #hashtag tag text, including the # symbol. **/
6 tag: string
7 /** If the hashtag is associated with a custom URL, this will be defined. **/
8 url?: string
9 /** If we should retain the hashtag, even if it does not exist in the comment text, when the comment is updated. Useful for tagging comments without changing comment text. **/
10 retain?: boolean
11}
12

Struktur der E-Mail-Vorlage Internal Link

Ein EmailTemplate-Objekt repräsentiert die Konfiguration für eine benutzerdefinierte E-Mail-Vorlage für einen Tenant.

Das System wählt die zu verwendende E-Mail-Vorlage über:

  • Ihren Typ-Identifikator, wir nennen dies emailTemplateId. Dies sind Konstanten.
  • Die domain. Wir versuchen zuerst, eine Vorlage für die Domain zu finden, mit der das zugehörige Objekt (wie ein Comment) verbunden ist, und wenn keine Übereinstimmung gefunden wird, versuchen wir, eine Vorlage zu finden, bei der domain null oder * ist.

Die Struktur des EmailTemplate-Objekts ist wie folgt:

E-Mail-Vorlagen Struktur
Copy Copy
1
2interface EmailTemplate {
3 id: string
4 tenantId: string
5 emailTemplateId: string
6 displayName: string
7 /** READONLY **/
8 createdAt: string
9 /** READONLY **/
10 updatedAt: string
11 /** READONLY **/
12 updatedByUserId: string
13 /** The domain the template should be associated with. **/
14 domain?: string | '*' | null
15 /** The email template content in EJS syntax. **/
16 ejs: string
17 /** A map of overridden translation keys to values, for each supported locale. **/
18 translationOverridesByLocale: Record<string, Record<string, string>>
19 /** An object that represents the render context of the template. **/
20 testData: object
21}
22

Hinweise

  • Sie können die gültigen emailTemplateId-Werte vom /definitions-Endpunkt abrufen.
  • Der /definitions-Endpunkt enthält auch die Standardübersetzungen und Testdaten.
  • Vorlagen können nicht gespeichert werden, wenn sie eine ungültige Struktur oder Testdaten haben.

Hashtag-Struktur Internal Link

Ein HashTag-Objekt repräsentiert ein Tag, das von einem Benutzer hinterlassen werden kann. HashTags können verwendet werden, um auf einen externen Inhalt zu verlinken oder um zusammengehörige Kommentare zu verbinden.

Die Struktur des HashTag-Objekts ist wie folgt:

HashTag Struktur
Copy Copy
1
2interface HashTag {
3 /** Should start with the "#" or desired character. **/
4 tag: string
5 /** An optional URL that the hashtag can point to. Instead of filtering comments by hashtag, the UI will redirect to this upon click. **/
6 url?: string
7 /** READONLY **/
8 createdAt: string
9}
10

Hinweise:

  • In einigen API-Endpunkten werden Sie sehen, dass der Hashtag in der URL verwendet wird. Denken Sie daran, Werte URL-zu-kodieren. Zum Beispiel sollte # stattdessen als %23 dargestellt werden.
  • Einige dieser Felder sind als READONLY markiert - diese werden von der API zurückgegeben, können aber nicht gesetzt werden.

Struktur der Anzahl der Benachrichtigungen Internal Link

Ein NotificationCount-Objekt repräsentiert die Anzahl ungelesener Benachrichtigungen und Metadaten für einen Benutzer.

Wenn es keine ungelesenen Benachrichtigungen gibt, existiert kein NotificationCount für den Benutzer.

NotificationCount-Objekte werden automatisch erstellt und können nicht über die API erstellt werden. Sie laufen auch nach einem Jahr ab.

Sie können den Zähler für ungelesene Benachrichtigungen eines Benutzers löschen, indem Sie seinen NotificationCount löschen.

Die Struktur des NotificationCount-Objekts ist wie folgt:

NotificationCount Struktur
Copy Copy
1
2interface NotificationCount {
3 id: string // user id
4 count: number
5 createdAt: string // date string
6 expireAt: string // date string
7}
8

Benachrichtigungsstruktur Internal Link

Ein Notification-Objekt repräsentiert eine Benachrichtigung für einen Benutzer.

Notification-Objekte werden automatisch erstellt und können nicht über die API erstellt werden. Sie laufen auch nach einem Jahr ab. Benachrichtigungen können nicht gelöscht werden. Sie können jedoch aktualisiert werden, um viewed auf false zu setzen, und Sie können nach viewed abfragen.

Ein Benutzer kann sich auch von Benachrichtigungen für einen bestimmten Kommentar abmelden, indem er optedOut in der Benachrichtigung auf true setzt. Sie können sich wieder anmelden, indem Sie es auf false setzen.

Es gibt verschiedene Benachrichtigungstypen - prüfen Sie relatedObjectType und type.

Die Art und Weise, wie Benachrichtigungen erstellt werden, ist recht flexibel und kann durch viele Szenarien ausgelöst werden (siehe NotificationType).

Stand heute bedeutet die Existenz einer Notification nicht tatsächlich, dass eine E-Mail gesendet wird oder werden sollte. Vielmehr werden die Benachrichtigungen für den Benachrichtigungs-Feed und verwandte Integrationen verwendet.

Die Struktur des Notification-Objekts ist wie folgt:

Benachrichtigung Struktur
Copy Copy
1
2enum NotificationObjectType {
3 Comment = 0,
4 Profile = 1,
5 Tenant = 2
6}
7
8enum NotificationType {
9 /** If someone replied to you. **/
10 RepliedToMe = 0,
11 /** If someone replied anywhere in a thread (even children of children) of a thread you commented on. **/
12 RepliedTransientChild = 1,
13 /** If your comment was up-voted. **/
14 VotedMyComment = 2,
15 /** If a new comment is left on the root of a page you're subscribed to. **/
16 SubscriptionReplyRoot = 3,
17 /** If someone commented on your profile. **/
18 CommentedOnProfile = 4,
19 /** If you have a DM. **/
20 DirectMessage = 5,
21 /** TrialLimits is for tenant users only. **/
22 TrialLimits = 6,
23 /** If you were @mentioned. **/
24 Mentioned = 7
25}
26
27interface Notification {
28 id: string
29 tenantId: string
30 /** With SSO, the user id is in the format `<tenant id>:<user id>`. **/
31 userId?: string
32 /** When working with SSO, you only have to worry about `userId`. **/
33 anonUserId?: string
34 /** urlId is almost always defined. It is only optional for tenant-level notifications, which are infrequent. **/
35 urlId?: string
36 /** URL is cached for quick navigation to the source of the notification. **/
37 url?: string
38 /** Page Title is cached for quick reading of notification source. **/
39 pageTitle?: string
40 relatedObjectType: NotificationObjectType
41 /** For example, comment id. **/
42 relatedObjectId: string
43 viewed: boolean
44 createdAt: string // date string
45 type: NotificationType
46 fromCommentId?: string
47 fromVoteId?: string
48 /** fromUserName and fromUserAvatarSrc are cached here for quick displaying of the notification. They are updated when the user is updated. **/
49 fromUserName: string
50 fromUserId: string
51 fromUserAvatarSrc?: string
52 /** Set this to true to stop getting notifications for this object. **/
53 optedOut?: boolean
54}
55

Seitenstruktur Internal Link

Ein Page-Objekt repräsentiert die Seite, zu der viele Kommentare gehören können. Diese Beziehung wird durch urlId definiert.

Eine Page speichert Informationen wie den Seitentitel, die Kommentaranzahl und die urlId.

Die Struktur des Page-Objekts ist wie folgt:

Seiten Struktur
Copy Copy
1
2interface Page {
3 id: string
4 urlId: string
5 url: string
6 title?: string
7 createdAt: string
8 commentCount: number
9 rootCommentCount: number
10 /** Setting this to null means all SSO users can see the page. An empty list means it is closed to all users. **/
11 accessibleByGroupIds?: string[] | null
12 /** Is this page closed for new comments? **/
13 isClosed?: boolean
14}
15

Struktur ausstehender Webhook-Ereignisse Internal Link

Ein PendingWebhookEvent-Objekt repräsentiert ein in der Warteschlange befindliches Webhook-Ereignis, das aussteht.

PendingWebhookEvent-Objekte werden automatisch erstellt und können nicht manuell über die API erstellt werden. Sie laufen auch nach einem Jahr ab. Sie können gelöscht werden, wodurch die Aufgabe aus der Warteschlange entfernt wird.

Es gibt verschiedene Ereignistypen - prüfen Sie eventType (OutboundSyncEventType) und type (OutboundSyncType).

Ein häufiger Anwendungsfall für diese API ist die Implementierung von benutzerdefiniertem Monitoring. Sie möchten vielleicht den /count-Endpunkt regelmäßig aufrufen, um die ausstehende Anzahl für gegebene Filter abzufragen.

Die Struktur des PendingWebhookEvent-Objekts ist wie folgt:

PendingWebhookEvent Struktur
Copy Copy
1
2enum OutboundSyncEventType {
3 Create: 0,
4 Delete: 1,
5 Update: 2
6}
7
8enum OutboundSyncType {
9 /** WordPress-specific sync task. **/
10 WP: 0,
11 Webhook: 1
12}
13
14interface PendingWebhookEvent {
15 id: string
16 /** The comment id associated with the event. **/
17 commentId: string
18 /** The comment object for the event at the time of the event. We started adding these in Nov 2023. **/
19 comment: Comment
20 /** An external id that may be associated with the comment. **/
21 externalId: string | null
22 createdAt: Date
23 tenantId: string
24 attemptCount: number
25 /** Set before first attempt, and after every failure. **/
26 nextAttemptAt: Date
27 /** Whether this is a creation, deletion, or update event... **/
28 eventType: OutboundSyncEventType
29 /** The type of sync to perform (WordPress, call API, etc). **/
30 type: OutboundSyncType
31 /** The domain that matched the comment. We use this domain to pick the API key. **/
32 domain: string
33 /** The last error that occurred. This type is untyped and is a "dump" of whatever happened. Usually it contains an object with statusCode, body, and a headers map. **/
34 lastError: object | null
35}
36

SSO-Benutzer-Struktur Internal Link

FastComments bietet eine einfach zu verwendende SSO-Lösung. Das Aktualisieren der Benutzerinformationen mit der HMAC-basierten Integration ist so einfach wie das Laden der Seite mit einem aktualisierten Payload durch den Benutzer.

Es kann jedoch wünschenswert sein, einen Benutzer außerhalb dieses Flows zu verwalten, um die Konsistenz Ihrer Anwendung zu verbessern.

Die SSO-Benutzer-API bietet eine Möglichkeit, Objekte zu erstellen, zu lesen, zu aktualisieren und zu löschen, die wir SSOUsers nennen. Diese Objekte unterscheiden sich von regulären Benutzern und werden aus Gründen der Typsicherheit getrennt gehalten.

Die Struktur des SSOUser-Objekts ist wie folgt:

SSOUser Struktur
Copy Copy
1
2interface SSOUser {
3 id: string
4 username: string
5 email?: string
6 websiteUrl?: string
7 signUpDate: number
8 createdFromUrlId?: string
9 loginCount?: number
10 avatarSrc?: string
11 optedInNotifications?: boolean
12 optedInSubscriptionNotifications?: boolean
13 displayLabel?: string
14 displayName?: string
15 isAccountOwner?: boolean // Admin permission - SSO users with this flag are billed as SSO Admins (separate from regular SSO users)
16 isAdminAdmin?: boolean // Admin permission - SSO users with this flag are billed as SSO Admins (separate from regular SSO users)
17 isCommentModeratorAdmin?: boolean // Moderator permission - SSO users with this flag are billed as SSO Moderators (separate from regular SSO users)
18 /** If null, Access Control will not be applied to the user. If an empty list, this user will not be able to see any pages or @mention other users. **/
19 groupIds?: string[] | null
20 createdFromSimpleSSO?: boolean
21 /** Don't let other users see this user's activity, including comments, on their profile. Default is true to provide secure profiles by default. **/
22 isProfileActivityPrivate?: boolean
23 /** Don't let other users leave comments on the user's profile, or see existing profile comments. Default false. **/
24 isProfileCommentsPrivate?: boolean
25 /** Don't let other users send direct messages to this user. Default false. **/
26 isProfileDMDisabled?: boolean
27 karma?: number
28 /** Optional configuration for user badges. **/
29 badgeConfig?: {
30 /** Array of badge IDs to assign to the user. Limited to 30 badges. Order is respected. **/
31 badgeIds: string[]
32 /** If true, replaces all existing displayed badges with the provided ones. If false, adds to existing badges. **/
33 override?: boolean
34 /** If true, updates badge display properties from tenant configuration. **/
35 update?: boolean
36 }
37}
38

Abrechnung für SSO-Benutzer

SSO-Benutzer werden je nach ihren Berechtigungsflags unterschiedlich abgerechnet:

  • Reguläre SSO-Benutzer: Benutzer ohne Admin- oder Moderatorberechtigungen werden als reguläre SSO-Benutzer abgerechnet
  • SSO-Admins: Benutzer mit isAccountOwner- oder isAdminAdmin-Flags werden separat als SSO-Admins abgerechnet (gleicher Tarif wie reguläre Tenant-Admins)
  • SSO-Moderatoren: Benutzer mit isCommentModeratorAdmin-Flag werden separat als SSO-Moderatoren abgerechnet (gleicher Tarif wie reguläre Moderatoren)

Wichtig: Um doppelte Abrechnung zu vermeiden, dedupliziert das System automatisch SSO-Benutzer gegen reguläre Tenant-Benutzer und Moderatoren nach E-Mail-Adresse. Wenn ein SSO-Benutzer dieselbe E-Mail wie ein regulärer Tenant-Benutzer oder Moderator hat, wird er nicht doppelt abgerechnet.

Zugriffskontrolle

Benutzer können in Gruppen aufgeteilt werden. Dafür ist das Feld groupIds da, und es ist optional.

@Mentions

Standardmäßig verwendet @mentions username, um nach anderen SSO-Benutzern zu suchen, wenn das @-Zeichen eingegeben wird. Wenn displayName verwendet wird, werden Ergebnisse, die mit username übereinstimmen, ignoriert, wenn es eine Übereinstimmung für displayName gibt, und die @mention-Suchergebnisse verwenden displayName.

Abonnements

Mit FastComments können Benutzer eine Seite abonnieren, indem sie auf das Glockensymbol im Kommentar-Widget klicken und auf Abonnieren klicken.

Bei einem regulären Benutzer senden wir ihm Benachrichtigungs-E-Mails basierend auf seinen Benachrichtigungseinstellungen.

Bei SSO-Benutzern teilen wir dies aus Gründen der Abwärtskompatibilität auf. Benutzer erhalten diese zusätzlichen Abonnement-Benachrichtigungs-E-Mails nur, wenn Sie optedInSubscriptionNotifications auf true setzen.

Badges

Sie können SSO-Benutzern Badges über die badgeConfig-Eigenschaft zuweisen. Badges sind visuelle Indikatoren, die neben dem Benutzernamen in Kommentaren erscheinen.

  • badgeIds - Ein Array von Badge-IDs, die dem Benutzer zugewiesen werden sollen. Diese müssen gültige Badge-IDs sein, die in Ihrem FastComments-Konto erstellt wurden. Auf 30 Badges begrenzt.
  • override - Wenn wahr, werden alle vorhandenen Badges, die in Kommentaren angezeigt werden, durch die bereitgestellten ersetzt. Wenn falsch oder weggelassen, werden die bereitgestellten Badges zu allen vorhandenen Badges hinzugefügt.
  • update - Wenn wahr, werden Badge-Anzeigeeigenschaften aus der Tenant-Konfiguration aktualisiert, wann immer sich der Benutzer anmeldet.

Abonnement-Struktur Internal Link

Ein Subscription-Objekt repräsentiert ein Abonnement für einen Benutzer.

Subscription-Objekte werden erstellt, wenn ein Benutzer auf das Benachrichtigungsglocken-Symbol im Kommentar-Widget klickt und "Diese Seite abonnieren" auswählt.

Abonnements können auch über die API erstellt werden.

Das Vorhandensein eines Subscription-Objekts bewirkt, dass Notification-Objekte generiert und E-Mails gesendet werden, wenn neue Kommentare am Wurzelknoten der zugehörigen Seite hinterlassen werden, für die das Subscription gilt. Das Senden von E-Mails hängt vom Benutzertyp ab. Für reguläre Benutzer hängt dies von optedInNotifications ab. Für SSO-Benutzer hängt dies von optedInSubscriptionNotifications ab. Beachten Sie, dass einige Anwendungen möglicherweise kein Konzept einer webzugänglichen Seite haben, in diesem Fall setzen Sie urlId einfach auf die ID des Elements, das Sie abonnieren (derselbe Wert für urlId, den Sie an das Kommentar-Widget übergeben würden).

Die Struktur des Subscription-Objekts ist wie folgt:

Abonnement Struktur
Copy Copy
1
2interface Subscription {
3 id: string
4 tenantId: string
5 /** With SSO, the user id is in the format `<tenant id>:<user id>`. **/
6 userId: string
7 anonUserId?: string
8 urlId: string
9 url?: string
10 pageTitle?: string
11 createdAt: string // date string
12}
13

Struktur der täglichen Mandantennutzung Internal Link

Ein TenantDailyUsage-Objekt repräsentiert die Nutzung für einen Tenant an einem bestimmten Tag. Wenn es keine Aktivität für einen bestimmten Tenant an einem bestimmten Tag gab, wird dieser Tag kein TenantDailyUsage-Objekt haben.

Das TenantDailyUsage-Objekt ist nicht in Echtzeit und kann einige Minuten hinter der tatsächlichen Nutzung zurückliegen.

Die Struktur des TenantDailyUsage-Objekts ist wie folgt:

TenantDailyUsage Struktur
Copy Copy
1
2export interface TenantDailyUsage {
3 yearNumber: number
4 monthNumber: number
5 dayNumber: number
6 commentFetchCount?: number
7 commentCreateCount?: number
8 conversationCreateCount?: number
9 voteCount?: number
10 accountCreatedCount?: number
11 userMentionSearch?: number
12 hashTagSearch?: number
13 gifSearchTrending?: number
14 gifSearch?: number
15 apiCreditsUsed?: number
16 createdAt: string
17 billed: boolean
18 /** Ignored for billing. **/
19 ignored: boolean
20}
21

Mandantenstruktur Internal Link

Der Tenant definiert einen FastComments.com-Kunden. Sie können über die API von Tenants mit White-Labeling-Zugang erstellt werden. White-Label-Tenants können keine anderen White-Label-Tenants erstellen (nur eine Verschachtelungsebene ist erlaubt).

Die Struktur des Tenant-Objekts ist wie folgt:

Tenant Struktur
Copy Copy
1
2export enum SiteType {
3 Unknown = 0,
4 WordPress = 1
5}
6
7/** This can also be handled via the DomainConfig API. **/
8export interface TenantDomainConfig {
9 domain: string
10 emailFromName?: string
11 emailFromEmail?: string
12 createdAt?: string,
13 siteType?: FastCommentsSiteType, // you probably want Unknown
14 logoSrc?: string, // raw image path
15 logoSrc100px?: string, // resized for thumbnails
16 footerUnsubscribeURL?: string,
17 emailHeaders?: Record<string, string>,
18 disableUnsubscribeLinks?: boolean,
19 dkim?: {
20 domainName: string,
21 keySelector: string,
22 privateKey: string
23 }
24}
25
26export interface TenantBillingInfo {
27 name: string
28 address: string
29 city: string
30 state: string
31 zip: string
32 country: string
33}
34
35export enum TenantPaymentFrequency {
36 Monthly = 0,
37 Annually = 1
38}
39
40export interface Tenant {
41 id: string
42 name: string
43 email?: string
44 signUpDate: number; // number due to "legacy" reasons
45 packageId?: string | null
46 paymentFrequency?: TenantPaymentFrequency
47 billingInfoValid?: boolean
48 billingHandledExternally?: boolean
49 createdBy?: string
50 isSetup?: boolean
51 domainConfiguration: FastCommentsAPITenantDomainConfig[]
52 billingInfo?: FastCommentsAPITenantBillingInfo
53 stripeCustomerId?: string
54 stripeSubscriptionId?: string
55 stripePlanId?: string
56 enableProfanityFilter?: boolean
57 enableSpamFilter?: boolean
58 lastBillingIssueReminderDate?: string
59 removeUnverifiedComments?: boolean
60 unverifiedCommentsTTLms?: number
61 commentsRequireApproval?: boolean
62 autoApproveCommentOnVerification?: boolean
63 sendProfaneToSpam?: boolean
64 /** @readonly - Is calculated based on packageId. **/
65 hasFlexPricing?: boolean
66 /** @readonly **/
67 flexLastBilledAmount?: number
68 /** @readonly - Is calculated based on packageId. **/
69 hasAuditing?: boolean
70 /** You can store a key value pair with the tenant which you can use to query. Keys cannot contain "." or "$", or be longer than 100 chars. Values may not be longer than 2k chars. **/
71 meta?: Record<string, string | null>
72}
73

Benutzerstruktur Internal Link

User ist ein Objekt, das den kleinsten gemeinsamen Nenner aller Benutzer darstellt.

Beachten Sie, dass wir bei FastComments verschiedene Anwendungsfälle für Benutzer haben:

  • Secure SSO
  • Simple SSO
  • Tenant-Benutzer (zum Beispiel: Administratoren)
  • Kommentierende

Diese API ist für Kommentierende und Benutzer, die über Simple SSO erstellt wurden. Grundsätzlich kann über diese API auf jeden Benutzer zugegriffen werden, der über Ihre Seite erstellt wurde. Tenant-Benutzer können auch auf diese Weise abgerufen werden, aber Sie erhalten mehr Informationen durch Interaktion mit der /tenant-users/-API.

Für Secure SSO verwenden Sie bitte die /sso-users/-API.

Sie können diese Arten von Benutzern nicht aktualisieren. Sie haben ihr Konto über Ihre Seite erstellt, daher bieten wir einen grundlegenden schreibgeschützten Zugang, aber Sie können keine Änderungen vornehmen. Wenn Sie diesen Flow haben möchten, müssen Sie Secure SSO einrichten.

Die Struktur des User-Objekts ist wie folgt:

User Struktur
Copy Copy
1
2export interface User {
3 /** This is also the id used as userId on comment objects. **/
4 id: string
5 username: string
6 /** A link to the commenter's blog, for example. **/
7 websiteUrl?: string
8 email: string
9 signUpDate: number
10 createdFromUrlId: string
11 createdFromTenantId: string
12 avatarSrc?: string
13 locale: FastCommentsLocale
14 displayLabel?: string
15 karma?: number
16}
17

Stimmenstruktur Internal Link

Ein Vote-Objekt repräsentiert eine Abstimmung, die von einem Benutzer hinterlassen wurde.

Die Beziehung zwischen Kommentaren und Abstimmung wird über commentId definiert.

Die Struktur des Vote-Objekts ist wie folgt:

Vote Struktur
Copy Copy
1
2interface Vote {
3 id: string
4 urlId: string
5 commentId: string
6 userId: string
7 direction: 1 | -1
8 createdAt: string
9}
10

Struktur der Fragekonfiguration Internal Link

FastComments bietet eine Möglichkeit, Fragen zu konstruieren und ihre Ergebnisse zu aggregieren. Ein Beispiel für eine Frage (im Folgenden QuestionConfig genannt) könnte eine Sternebewertung, ein Schieberegler oder eine NPS-Frage sein (bestimmt durch type).

Fragedaten können einzeln, zusammen, über Zeit, insgesamt, nach Seite usw. aggregiert werden.

Das Framework hat alle Fähigkeiten, die benötigt werden, um clientseitige Widgets (mit Ihrem Server vor dieser API), Admin-Dashboards und Reporting-Tools zu erstellen.

Zuerst müssen wir eine QuestionConfig definieren. Die Struktur ist wie folgt:

QuestionConfig Struktur
Copy Copy
1
2type QuestionConfigType = 'nps' | 'slider' | 'star' | 'thumbs';
3
4interface QuestionConfig {
5 id: string
6 tenantId: string
7 name: string
8 question: string
9 helpText?: string
10 createdAt: string
11 createdBy: string
12 /** READONLY - incremented for each new response. **/
13 usedCount: number
14 /** A date string for when the configuration was last used (result left). **/
15 lastUsed?: string
16 type: QuestionConfigType
17 numStars?: number
18 min?: number
19 max?: number
20 defaultValue?: number
21 labelNegative?: string
22 labelPositive?: string
23 subQuestionIds?: string[]
24 alwaysShowSubQuestions?: boolean
25 reportingOrder: number
26}
27

Struktur des Frageergebnisses Internal Link

Um Ergebnisse für Fragen zu speichern, erstellen Sie ein QuestionResult. Sie können dann Frageergebnisse aggregieren und sie auch zu Berichtszwecken mit Kommentaren verknüpfen.

QuestionResult Struktur
Copy Copy
1
2interface QuestionResultMeta {
3 name: string
4 values: string[]
5}
6
7interface QuestionResult {
8 id: string
9 tenantId: string
10 urlId: string
11 anonUserId?: string
12 userId?: string
13 createdAt?: string
14 value: number
15 commentId?: string
16 questionId: string
17 meta?: QuestionResultMeta[]
18}
19

Struktur des Benutzerabzeichens Internal Link

UserBadge ist ein Objekt, das ein einem Benutzer im FastComments-System zugewiesenes Badge darstellt.

Badges können Benutzern automatisch basierend auf ihrer Aktivität (wie Kommentaranzahl, Antwortzeit, Veteran-Status) oder manuell von Site-Administratoren zugewiesen werden.

Die Struktur des UserBadge-Objekts ist wie folgt:

UserBadge Struktur
Copy Copy
1
2export interface UserBadge {
3 /** Unique identifier for this user badge assignment */
4 id: string
5 /** ID of the user this badge is assigned to */
6 userId: string
7 /** ID of the badge definition from the tenant's badge catalog */
8 badgeId: string
9 /** ID of the tenant that created/assigned this badge */
10 fromTenantId: string
11 /** When this badge was created (milliseconds since epoch) */
12 createdAt?: number
13 /** When this badge was received by the user (milliseconds since epoch) */
14 receivedAt?: number
15 /**
16 * The badge type:
17 * 0=CommentCount, 1=CommentUpVotes, 2=CommentReplies, 3=CommentsPinned,
18 * 4=Veteran, 5=NightOwl, 6=FastReplyTime, 7=ModeratorCommentsDeleted,
19 * 8=ModeratorCommentsApproved, 9=ModeratorCommentsUnapproved, 10=ModeratorCommentsReviewed,
20 * 11=ModeratorCommentsMarkedSpam, 12=ModeratorCommentsMarkedNotSpam, 13=RepliedToSpecificPage,
21 * 14=Manual
22 */
23 type: number
24 /** For threshold-based badges, the threshold value */
25 threshold?: number
26 /** The name/label of the badge */
27 name?: string
28 /** Detailed description of the badge */
29 description?: string
30 /** The text shown on the badge */
31 displayLabel?: string
32 /** URL to an image shown on the badge */
33 displaySrc?: string
34 /** Background color for the badge (hex code) */
35 backgroundColor?: string
36 /** Border color for the badge (hex code) */
37 borderColor?: string
38 /** Text color for the badge (hex code) */
39 textColor?: string
40 /** Additional CSS class for styling */
41 cssClass?: string
42 /** For veteran badges, the time threshold in milliseconds */
43 veteranUserThresholdMillis?: number
44 /** Whether this badge is displayed on the user's comments */
45 displayedOnComments: boolean
46 /** The display order of the badge */
47 order?: number
48}
49

Struktur des Fortschritts bei Benutzerabzeichen Internal Link

UserBadgeProgress ist ein Objekt, das den Fortschritt eines Benutzers beim Verdienen verschiedener Badges im FastComments-System darstellt.

Diese Verfolgung hilft zu bestimmen, wann Benutzer automatische Badges basierend auf ihrer Aktivität und Teilnahme in Ihrer Community erhalten sollten.

Die Struktur des UserBadgeProgress-Objekts ist wie folgt:

UserBadgeProgress Struktur
Copy Copy
1
2export interface UserBadgeProgress {
3 /** Unique identifier for this progress record */
4 id: string
5 /** ID of the tenant this progress record belongs to */
6 tenantId: string
7 /** ID of the user this progress record tracks */
8 userId: string
9 /** ID of the user's first comment in the system */
10 firstCommentId?: string
11 /** Date of the user's first comment (milliseconds since epoch) */
12 firstCommentDate?: number
13 /** Automatically calculated trust factor based on user activity */
14 autoTrustFactor?: number
15 /** Manually set trust factor by administrators */
16 manualTrustFactor?: number
17 /** Detailed progress object with various metrics, keys match BadgeType enum */
18 progress: {
19 /** 0: CommentCount - Count of comments the user has made */
20 '0'?: number
21 /** 1: CommentUpVotes - Count of upvotes the user has received */
22 '1'?: number
23 /** 2: CommentReplies - Count of replies the user has made */
24 '2'?: number
25 /** 3: CommentsPinned - Count of pinned comments the user has */
26 '3'?: number
27 /** 4: Veteran - User's account age */
28 '4'?: number
29 /** 5: NightOwl - Times user has posted during nighttime hours */
30 '5'?: number
31 /** 6: FastReplyTime - Average reply time in milliseconds */
32 '6'?: number
33 /** 7: ModeratorCommentsDeleted - For moderator badges, comments deleted count */
34 '7'?: number
35 /** 8: ModeratorCommentsApproved - For moderator badges, comments approved count */
36 '8'?: number
37 /** 9: ModeratorCommentsUnapproved - For moderator badges, comments unapproved count */
38 '9'?: number
39 /** 10: ModeratorCommentsReviewed - For moderator badges, comments reviewed count */
40 '10'?: number
41 /** 11: ModeratorCommentsMarkedSpam - For moderator badges, comments marked as spam count */
42 '11'?: number
43 /** 12: ModeratorCommentsMarkedNotSpam - For moderator badges, comments marked as not spam count */
44 '12'?: number
45 /** 13: RepliedToSpecificPage - For each page, count of replies */
46 '13'?: Record<string, number>
47 }
48}
49

Abschließend

Wir hoffen, dass Sie unsere API-Dokumentation als umfassend und leicht verständlich empfunden haben. Wenn Sie Lücken feststellen, lassen Sie es uns unten wissen.