FastComments.com

L'API FastComments

FastComments fournit une API pour interagir avec de nombreuses ressources. Créez des intégrations avec notre plateforme, ou même développez vos propres clients !

Dans cette documentation, vous trouverez toutes les ressources prises en charge par l'API documentées avec leurs types de requête et de réponse.

Pour les clients Enterprise, tout accès à l'API est enregistré dans le journal d'audit.

SDKs générés

FastComments génère désormais une Spécification d'API à partir de notre code (ce n'est pas encore complet, mais inclut de nombreuses API).

Nous disposons désormais de SDKs pour les langages populaires :

Authentification

L'API est authentifiée en transmettant votre clé API soit via un en-tête X-API-KEY, soit via un paramètre de requête API_KEY. Vous aurez également besoin de votre tenantId pour effectuer des appels à l'API. Celui-ci peut être récupéré depuis la même page que votre clé API.

Note de sécurité

Ces routes sont destinées à être appelées depuis un serveur. NE LES APPELEZ PAS depuis un navigateur. Le faire exposera votre clé API — cela donnera un accès complet à votre compte à toute personne pouvant voir le code source d'une page !

Option d'authentification 1 - En-têtes

  • En-tête : X-API-KEY
  • En-tête : X-TENANT-ID

Option d'authentification 2 - Paramètres de requête

  • Paramètre de requête : API_KEY
  • Paramètre de requête : tenantId

Structure du journal d'audit Internal Link

Un AuditLog est un objet qui représente un événement audité pour les locataires qui ont accès à cette fonctionnalité.

La structure de l'objet AuditLog est la suivante :

Structure AuditLog
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

Le journal d'audit est immuable. Il ne peut pas non plus être écrit manuellement. FastComments.com est le seul à décider quand écrire dans le journal d'audit. Cependant, vous pouvez le lire via cette API.

Les événements dans le journal d'audit expirent après deux ans.

Structure de commentaire Internal Link

Un objet Comment représente un commentaire laissé par un utilisateur.

La relation entre les commentaires parents et enfants est définie via parentId.

La structure de l'objet Comment est la suivante :

Structure de Comment
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

Certains de ces champs sont marqués READONLY - ils sont retournés par l'API mais ne peuvent pas être définis.

Structure du texte de commentaire

Les commentaires sont écrits dans une version FastComments de markdown, qui est simplement markdown plus des balises de style bbcode traditionnelles pour les images, comme [img]path[/img].

Le texte est stocké dans deux champs. Le texte entré par l'utilisateur est stocké non modifié dans le champ comment. Il est rendu et stocké dans le champ commentHTML.

Les balises HTML autorisées sont b, u, i, strike, pre, span, code, img, a, strong, ul, ol, li, et br.

Il est recommandé de rendre le HTML, car c'est un sous-ensemble très petit de HTML, construire un moteur de rendu est assez simple. Il existe plusieurs bibliothèques pour React Native et Flutter, par exemple, pour aider avec cela.

Vous pouvez choisir de rendre la valeur non normalisée du champ comment. Un exemple d'analyseur est ici..

L'exemple d'analyseur pourrait également être ajusté pour fonctionner avec HTML, et transformer les balises HTML en éléments attendus à rendre pour votre plateforme.

Marquage

Lorsque des utilisateurs sont tagués dans un commentaire, l'information est stockée dans une liste appelée mentions. Chaque objet dans cette liste a la structure suivante.

L'objet Mentions de Commentaire
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

Lorsque des hashtags sont utilisés et analysés avec succès, l'information est stockée dans une liste appelée hashTags. Chaque objet dans cette liste a la structure suivante. Les hashtags peuvent également être ajoutés manuellement au tableau hashTags du commentaire pour la requête, si retain est défini.

L'objet HashTag de Commentaire
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

Structure de modèle d'e-mail Internal Link

Un objet EmailTemplate représente la configuration d'un modèle d'email personnalisé, pour un locataire.

Le système sélectionnera le modèle d'email à utiliser via :

  • Son identifiant de type, nous l'appelons emailTemplateId. Ce sont des constantes.
  • Le domain. Nous essaierons d'abord de trouver un modèle pour le domaine auquel l'objet associé (comme un Comment) est lié, et si aucune correspondance n'est trouvée, nous essaierons de trouver un modèle où le domaine est null ou *.

La structure de l'objet EmailTemplate est la suivante :

Structure de Modèle d'Email
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

Notes

  • Vous pouvez obtenir les valeurs valides de emailTemplateId depuis l'endpoint /definitions.
  • L'endpoint /definitions inclut également les traductions et données de test par défaut.
  • Les modèles échoueront à l'enregistrement avec une structure ou des données de test invalides.

Structure de hashtag Internal Link

Un objet HashTag représente un tag qui peut être laissé par un utilisateur. Les HashTags peuvent être utilisés pour créer un lien vers un contenu externe ou pour relier des commentaires connexes ensemble.

La structure de l'objet HashTag est la suivante :

Structure de HashTag
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

Notes :

  • Dans certains endpoints API, vous verrez que le hashtag est utilisé dans l'URL. N'oubliez pas d'encoder les valeurs en URI. Par exemple, # devrait être représenté comme %23.
  • Certains de ces champs sont marqués READONLY - ils sont retournés par l'API mais ne peuvent pas être définis.

Structure du compteur de notifications Internal Link

Un objet NotificationCount représente le compteur de notifications non lues et les métadonnées pour un utilisateur.

S'il n'y a pas de notifications non lues, il n'y aura pas de NotificationCount pour l'utilisateur.

Les objets NotificationCount sont créés automatiquement et ne peuvent pas être créés via l'API. Ils expirent également après un an.

Vous pouvez effacer le compteur de notifications non lues d'un utilisateur en supprimant son NotificationCount.

La structure de l'objet NotificationCount est la suivante :

Structure de NotificationCount
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

Structure des notifications Internal Link

Un objet Notification représente une notification pour un utilisateur.

Les objets Notification sont créés automatiquement et ne peuvent pas être créés via l'API. Ils expirent également après un an. Les notifications ne peuvent pas être supprimées. Elles peuvent cependant être mises à jour pour définir viewed à false, et vous pouvez filtrer par viewed.

Un utilisateur peut également se désabonner des notifications pour un commentaire spécifique en définissant optedOut dans la notification à true. Vous pouvez vous réabonner en le définissant à false.

Il existe différents types de notifications - vérifiez relatedObjectType et type.

Les façons dont les notifications sont créées sont assez flexibles et peuvent être déclenchées par de nombreux scénarios (voir NotificationType).

À ce jour, l'existence d'une Notification n'implique pas réellement qu'un email est ou devrait être envoyé. Plutôt, les notifications sont utilisées pour le fil de notifications et les intégrations connexes.

La structure de l'objet Notification est la suivante :

Structure de Notification
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

Structure de la page Internal Link

Un objet Page représente la page à laquelle plusieurs commentaires peuvent appartenir. Cette relation est définie par urlId.

Une Page stocke des informations telles que le titre de la page, le nombre de commentaires et urlId.

La structure de l'objet Page est la suivante :

Structure de Page
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

Structure d'événement webhook en attente Internal Link

Un objet PendingWebhookEvent représente un événement webhook en file d'attente qui est en attente.

Les objets PendingWebhookEvent sont créés automatiquement et ne peuvent pas être créés manuellement via l'API. Ils expirent également après un an. Ils peuvent être supprimés, ce qui retire la tâche de la file d'attente.

Il existe différents types d'événements - vérifiez eventType (OutboundSyncEventType) et type (OutboundSyncType).

Un cas d'utilisation courant pour cette API est d'implémenter une surveillance personnalisée. Vous pouvez vouloir appeler l'endpoint /count périodiquement pour interroger le compteur en attente pour des filtres donnés.

La structure de l'objet PendingWebhookEvent est la suivante :

Structure de PendingWebhookEvent
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

Structure d'utilisateur SSO Internal Link

FastComments fournit une solution SSO facile à utiliser. La mise à jour des informations d'un utilisateur avec l'intégration basée sur HMAC est aussi simple que de faire charger la page à l'utilisateur avec un payload mis à jour.

Cependant, il peut être souhaitable de gérer un utilisateur en dehors de ce flux, pour améliorer la cohérence de votre application.

L'API SSO User fournit un moyen de faire du CRUD sur des objets que nous appelons SSOUsers. Ces objets sont différents des Users réguliers et gardés séparés pour la sécurité de type.

La structure de l'objet SSOUser est la suivante :

Structure de SSOUser
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

Facturation pour les Utilisateurs SSO

Les utilisateurs SSO sont facturés différemment selon leurs drapeaux de permission :

  • Utilisateurs SSO Réguliers : Les utilisateurs sans permissions d'administrateur ou de modérateur sont facturés comme utilisateurs SSO réguliers
  • Administrateurs SSO : Les utilisateurs avec les drapeaux isAccountOwner ou isAdminAdmin sont facturés séparément comme administrateurs SSO (même tarif que les administrateurs de locataire réguliers)
  • Modérateurs SSO : Les utilisateurs avec le drapeau isCommentModeratorAdmin sont facturés séparément comme modérateurs SSO (même tarif que les modérateurs réguliers)

Important : Pour éviter la double facturation, le système déduplique automatiquement les utilisateurs SSO par rapport aux utilisateurs et modérateurs de locataire réguliers par adresse email. Si un utilisateur SSO a le même email qu'un utilisateur ou modérateur de locataire régulier, il ne sera pas facturé deux fois.

Contrôle d'Accès

Les utilisateurs peuvent être divisés en groupes. C'est à cela que sert le champ groupIds, et c'est optionnel.

@Mentions

Par défaut, @mentions utilisera username pour rechercher d'autres utilisateurs SSO lorsque le caractère @ est tapé. Si displayName est utilisé, alors les résultats correspondant à username seront ignorés lorsqu'il y a une correspondance pour displayName, et les résultats de recherche @mention utiliseront displayName.

Abonnements

Avec FastComments, les utilisateurs peuvent s'abonner à une page en cliquant sur l'icône de cloche dans le widget de commentaires et en cliquant sur S'abonner.

Avec un utilisateur régulier, nous leur envoyons des emails de notification basés sur leurs paramètres de notification.

Avec les utilisateurs SSO, nous séparons cela pour la rétrocompatibilité. Les utilisateurs ne recevront ces emails de notification d'abonnement supplémentaires que si vous définissez optedInSubscriptionNotifications à true.

Badges

Vous pouvez attribuer des badges aux utilisateurs SSO en utilisant la propriété badgeConfig. Les badges sont des indicateurs visuels qui apparaissent à côté du nom d'un utilisateur dans les commentaires.

  • badgeIds - Un tableau d'IDs de badges à attribuer à l'utilisateur. Ceux-ci doivent être des IDs de badges valides créés dans votre compte FastComments. Limité à 30 badges.
  • override - Si vrai, tous les badges existants affichés sur les commentaires seront remplacés par ceux fournis. Si faux ou omis, les badges fournis seront ajoutés aux badges existants.
  • update - Si vrai, les propriétés d'affichage des badges seront mises à jour depuis la configuration du locataire chaque fois que l'utilisateur se connecte.

Structure d'abonnement Internal Link

Un objet Subscription représente un abonnement pour un utilisateur.

Les objets Subscription sont créés lorsqu'un utilisateur clique sur la cloche de notification dans le widget de commentaires et clique sur "S'abonner à cette page".

Les abonnements peuvent également être créés via l'API.

Avoir un objet Subscription provoque la génération d'objets Notification, et l'envoi d'emails, lorsque de nouveaux commentaires sont laissés à la racine de la page associée à laquelle le Subscription est destiné. L'envoi d'emails dépend du type d'utilisateur. Pour les utilisateurs réguliers, cela dépend de optedInNotifications. Pour les utilisateurs SSO, cela dépend de optedInSubscriptionNotifications. Notez que certaines applications peuvent ne pas avoir le concept de page accessible sur le web, auquel cas définissez simplement urlId sur l'id de l'élément auquel vous vous abonnez (même valeur pour urlId que vous passeriez au widget de commentaires).

La structure de l'objet Subscription est la suivante :

Structure de Subscription
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

Structure d'utilisation quotidienne du tenant Internal Link

Un objet TenantDailyUsage représente l'utilisation pour un locataire sur un jour donné. S'il n'y a eu aucune activité pour un locataire donné sur un jour donné, ce jour n'aura pas d'objet TenantDailyUsage.

L'objet TenantDailyUsage n'est pas en temps réel et peut être en retard de quelques minutes par rapport à l'utilisation réelle.

La structure pour l'objet TenantDailyUsage est la suivante:

Structure de TenantDailyUsage
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

Structure du tenant Internal Link

Le Tenant définit un client FastComments.com. Ils peuvent être créés via l'API par des locataires ayant accès au white labeling. Les locataires en white label ne peuvent pas créer d'autres locataires en white label (un seul niveau d'imbrication est autorisé).

La structure de l'objet Tenant est la suivante :

Structure de Tenant
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

Structure de l'utilisateur Internal Link

User est un objet qui représente un dénominateur commun de tous les utilisateurs.

Gardez à l'esprit qu'à FastComments nous avons un tas de cas d'utilisation différents pour les utilisateurs :

  • SSO Sécurisé
  • SSO Simple
  • Utilisateurs Locataires (Par exemple : Administrateurs)
  • Commentateurs

Cette API est pour les Commentateurs et les utilisateurs créés via SSO Simple. En gros, tout utilisateur créé via votre site peut être accédé via cette API. Les utilisateurs locataires peuvent également être récupérés de cette façon, mais vous obtiendrez plus d'informations en interagissant avec l'API /tenant-users/.

Pour le SSO Sécurisé veuillez utiliser l'API /sso-users/.

Vous ne pouvez pas mettre à jour ces types d'utilisateurs. Ils ont créé leur compte via votre site, donc nous fournissons un accès en lecture seule basique, mais vous ne pouvez pas faire de modifications. Si vous voulez avoir ce type de flux - vous devez configurer le SSO Sécurisé.

La structure de l'objet User est la suivante :

Structure de User
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

Structure du vote Internal Link

Un objet Vote représente un vote laissé par un utilisateur.

La relation entre les commentaires et le vote est définie via commentId.

La structure de l'objet Vote est la suivante :

Structure de Vote
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

Structure de configuration des questions Internal Link

FastComments fournit un moyen de construire des questions et d'agréger leurs résultats. Un exemple de question (ci-après appelée QuestionConfig) pourrait être une évaluation par étoiles, un curseur, ou une question NPS (déterminé via type).

Les données de question peuvent être agrégées individuellement, ensemble, au fil du temps, globalement, par page, et ainsi de suite.

Le framework a toutes les capacités nécessaires pour construire des widgets côté client (avec votre serveur devant cette API), des tableaux de bord d'administration, et des outils de rapports.

D'abord, nous devons définir un QuestionConfig. La structure est la suivante:

Structure de QuestionConfig
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

Structure des résultats des questions Internal Link

Afin de sauvegarder les résultats des questions, vous créez un QuestionResult. Vous pouvez ensuite agréger les résultats de questions, et aussi les lier aux commentaires à des fins de rapports.

Structure de QuestionResult
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

Structure du badge utilisateur Internal Link

UserBadge est un objet qui représente un badge attribué à un utilisateur dans le système FastComments.

Les badges peuvent être attribués aux utilisateurs automatiquement en fonction de leur activité (comme le nombre de commentaires, le temps de réponse, le statut de vétéran) ou manuellement par les administrateurs du site.

La structure de l'objet UserBadge est la suivante :

Structure de UserBadge
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

Structure de progression du badge utilisateur Internal Link

UserBadgeProgress est un objet qui représente la progression d'un utilisateur vers l'obtention de divers badges dans le système FastComments.

Ce suivi aide à déterminer quand les utilisateurs devraient recevoir des badges automatiques en fonction de leur activité et participation dans votre communauté.

La structure de l'objet UserBadgeProgress est la suivante :

Structure de UserBadgeProgress
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

En conclusion

Nous espérons que vous avez trouvé notre documentation de l'API complète et facile à comprendre. Si vous trouvez des lacunes, faites-nous savoir ci-dessous.