Giter VIP home page Giter VIP logo

datasift-dotnet's Introduction

DataSift .NET Client Library

This is the official .NET library for accessing Datasift.

Please log any library issues inside this GitHub repository.

Getting Started

To get started choose one of our quick start guides:

Installation

1) Sign-up to DataSift

You can sign up to DataSift for free at http://datasift.com.

Once you've registered you can find your username and API key on your Dashboard.

2) Reference DataSift library

The easiest way to use this library is via Nuget.

You can install the package using the Package Manager Console in Visual Studio.

    Install-Package Datasift.net 

Of course you could also download this source code and reference the DataSift project in your solution.

Usage: REST API Calls

    var client = new DataSiftClient("YOUR_USERNAME", "YOUR_APIKEY");
    var compiled = client.Compile("interaction.content contains \"music\"");
    Console.WriteLine("Compiled to {0}, DPU = {1}", compiled.Data.hash, compiled.Data.dpu);

See the DataSiftExamples project for some simple example usage.

Usage: Streaming Data

    class Program
    {
        private static DataSiftClient _client = null;
        private static DataSift.Streaming.DataSiftStream _stream = null;

        static void Main(string[] args)
        {
            // Create a new client
            _client = new DataSiftClient("YOUR_USERNAME", "YOUR_APIKEY");

            // Declare event handlers
            _stream.OnConnect += stream_OnConnect;
            _stream.OnMessage += stream_OnMessage;
            _stream.OnDataSiftMessage += stream_OnDataSiftMessage;

            // Connect
            _stream = _client.Connect();
        }

        static void stream_OnConnect()
        {
            Console.WriteLine("Connected.");

            // Compile and subscribe to a stream
            var compiled = _client.Compile("interaction.content contains \"football\"");
            Console.WriteLine("Compiled stream to {0}, DPU = {1}", compiled.Data.hash, compiled.Data.dpu);
            _stream.Subscribe(compiled.Data.hash);
        }

        static void stream_OnMessage(string hash, dynamic message)
        {
            Console.WriteLine("New interaction received on stream " + hash);
            Console.WriteLine(JsonConvert.SerializeObject(message) + "\n");
        }

        static void stream_OnDataSiftMessage(DataSift.Enum.DataSiftMessageStatus status, string message)
        {
            switch (status)
            {
                case DataSiftMessageStatus.Warning:
                    Console.WriteLine("WARNING: " + message);
                    break;
                case DataSiftMessageStatus.Failure:
                    Console.WriteLine("FAILURE: " + message);
                    break;
                case DataSiftMessageStatus.Success:
                    Console.WriteLine("SUCCESS: " + message);
                    break;
            }
        }
    }

See the DataSiftExamples project for some simple example usage.

Requirements

This library has been tested with the following frameworks:

  • .NET Framework 4.5

License

All code contained in this repository is Copyright MediaSift Ltd.

This code is released under the BSD license. Please see the LICENSE file for more details.

Change Log

  • 1.6.0 - Moved library to use v1.6 of the DataSift API, updated to use TLS v1.2.
  • 1.5.2 - Updated to v105 of RestSharp dependency
  • 1.5.1 - Added support for the Reference Data API.
  • 1.5.0 - Moved library to use v1.5 of the DataSift API, including support for Media Strategies API.
  • 1.4.0 - Moved library to use v1.4 of the DataSift API, including task endpoints.
  • 1.3.2 - Added 'analyze_queries' limit for identities.
  • 1.3.1 - Fixed format validation for PYLON recording ids.
  • 1.3.0 - Moved library to use v1.3 of the DataSift API, including pylon/update endpoint.
  • 1.2.4 - Added support for /pylon/sample endpoint
  • 1.2.3 - Added support for /account/usage endpoint
  • 1.2.2 - Changes to allow inheritance of client
  • 1.2.1 - Added support for ODP ingestion endpoint
  • 1.2.0 - Moved library to use v1.2 of the DataSift API
  • 1.1.2 - Fixed Nuget issue
  • 1.1.1 - PYLON GA Release
  • 1.1.0 - Added Pylon endpoints
  • 1.0.4 - Fixed Code Contract packaging issue (another!)
  • 1.0.3 - Fixed Code Contract packaging issue
  • 1.0.2 - Fixed issue 17 - Fixed unsubscribing from a stream
  • 1.0.0 - Completed rewrite of library

datasift-dotnet's People

Contributors

richcaudle avatar jonparish avatar zcourts avatar dugjason avatar aszac avatar

Stargazers

 avatar Martin Lundberg avatar Davide Covato avatar Mohamed F. Deifalla avatar Pavitar Dua avatar Ed Segura avatar  avatar Sreenadh avatar Sam Judson avatar  avatar Jamie avatar Tom Robinson avatar

Watchers

Will James avatar  avatar Ollie Parsley avatar  avatar Ivan Shaovchev avatar Lorenzo Alberton avatar Nick Halstead avatar Daniel Saxil-Nielsen avatar Tim Shea avatar Juan Carlos Alonso avatar Brad Hubbard avatar James Cloos avatar Akshay Shirahatti avatar  avatar Carl Dean Tucker avatar Ed Stenson avatar  avatar Nicola Asuni avatar Marcin Cabaj avatar  avatar  avatar jon rognerud avatar Rob Hubbard avatar Silvija avatar  avatar Victor avatar Nathan Macnamara avatar  avatar  avatar Paul Mozo avatar Linton Baddeley avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar Alessio Martorelli avatar David Shrive avatar Gary Goodger avatar Chris Knight avatar Ryan Stanley avatar  avatar  avatar Chris Young avatar  avatar  avatar

datasift-dotnet's Issues

Get JSON into Raven

I would like to store the interaction into RavenDB but storing Interaction produces no data I assume because of the way Interaction is a JToken. Can you suggest how to store an interaction as a type into Raven?

Definition.getBuffered with only a hash

Hi

I'm trying to run a definition using only a hash, but to get this to work I had to change the getBuffered to check for m_hash.Length == 0 as well:

if (m_csdl.Length == 0 && m_hash.Length == 0)
{
    throw new InvalidDataException("...");
}

Does this sound right, or should I be calling something else first?

My calling code looks like this:

var u = new User(Username, ApiKey);
var def = new Definition(u, "", hash);
return def.getBuffered(5);

Support v7.0.x of JSON.Net

When using the client library in a project that references v7.0 of JSON.Net calling client.Pylon.Start() with a legitimate hash gives an error that Newtonsift.Json.dll 6.0.0 cannot be found.

Error parsing JSON in some circumstances

In some circumstances when using the .NET library it can throw a 'JSON key does not exist' exception.

This was found when retrieving usage statistics and the user specified a licence type with a '.' in it. For example if you use 'klout.score'

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.