Data collection clients

The following article lists NET SDK data collection clients, along with their constructors, methods, and some sample code.

Interaction client

The InteractionClient is recommended way of reporting sentences, metadata (both subject and object), and mappings to DEC since version 1.1.5 of the .NET SDK.

Constructors

  • public InteractionClient(string datacenterKey)
    This is your default choice for instantiating the InteractionClient. You need to provide the API Key of the data center you wish to report data to. The client automatically targets the default live instance of the United States DEC API Server.
  • public InteractionClient(string serverAddress, string datacenterKey)
    This constructor takes an additional server address parameter, making it possible to target a DEC API Server different than the default United States one.

Methods

  • public Task<IImportResult> ImportInteractions(string dataSource, IEnumerable<Interaction> interactions)
    Used to report a collection of interactions under the provided data source.
  • public Task<IImportResult> ImportInteraction(string dataSource, Interaction interaction)
    Used to report a single interaction under the provided data source.

Sample code

The example below demonstrates how to report a sentence, subject, and object metadata, and a mapping  with single interaction to the website data source. Note that the client does not require you to authenticate:

You can also send multiple interactions, for example, metadata and mapping without explicit feature(predicate and object) action specified in them:

Sentence client

Prior to version 1.1.5 of the DEC .NET SDK, this client was the only way of sending sentences and subject metadata. It is present in the latest versions of the SDK for backward compatibility.

We recommend replacing the sentence client entirely in your code with the new InteractionClient.

Constructors

  • public SentenceClient(string datacenterKey)
  • public SentenceClient(string serverAddress, string datacenterKey)

Methods

  • public Task<IImportResult> ImportSentences(string dataSource, IEnumerable<Sentence> sentences)
  • public Task<IImportResult> ImportSentence(string dataSource, Sentence sentence)
  • public Task<IImportResult> ImportSubjectMetadata(string dataSource, SubjectMetadata metadata)
  • public Task<IImportResult> ImportSubjectMetadata(string dataSource, IEnumerable<SubjectMetadata> metadata)

Sample code

The sample code below demonstrates how to create and report a sentence and subject metadata. Note that the client does not require you to authenticate:

You can also include the subject metadata directly in the first sentence by adding key and value to the SubjectMetadata property:

sentence.SubjectMetadata.Add("Email", "john.smith@mail.com");

Subject mapping client

Prior to version 1.1.5 of the .NET SDK, this client was the only way of sending mappings to DEC. It is present in the latest versions of the SDK for backward compatibility.

We recommend replacing the sentence client entirely in your code with the new SubjectMappingClient.

Constructors

  • public SubjectMappingClient(string datacenterKey)
  • public SubjectMappingClient(string serverAddress, string datacenterKey)

Methods

  • public Task<IImportResult> ImportSubjectMappings(IEnumerable<SubjectMapping> mappings)
  • public Task<IImportResult> ImportSubjectMapping(SubjectMapping mapping)

Sample code

The following code demonstrates how to send a mapping. Note that the client does not require you to authenticate:

Was this article helpful?