Code Monkey home page Code Monkey logo

soda.net's Introduction

SODA.NET Build status

A Socrata Open Data API (SODA) client library targeting .NET 4.5 and above.

Getting Started

SODA.NET is available as a NuGet package.

Install-Package CSM.SodaDotNet

Usage examples

Simple, read-only access

//initialize a new client
//make sure you register for your own app token (http://dev.socrata.com/register)
var client = new SodaClient("data.smgov.net", "REPLACE_WITH_YOUR_APP_TOKEN");

//read metadata of a dataset using the resource identifier (Socrata 4x4)
var metadata = client.GetMetadata("1234-wxyz");
Console.WriteLine("{0} has {1} views.", metadata.Name, metadata.ViewsCount);

//get a reference to the resource itself
//the result (a Resouce object) is a generic type
//the type parameter represents the underlying rows of the resource
var dataset = client.GetResource<Dictionary<string, object>>("1234-wxyz");

//of course, a custom type can be used as long as it is JSON serializable
var dataset = client.GetResource<MyClass>("1234-wxyz");

//Resource objects read their own data
var allRows = dataset.GetRows();
var first10Rows = dataset.GetRows(10);

//collections of an arbitrary type can be returned
//using SoQL and a fluent query building syntax
var soql = new SoqlQuery().Select("column1", "column2")
                          .Where("something > nothing")
                          .Group("column3");

var results = dataset.Query<MyOtherClass>(soql);

SodaClient is also capable of performing write operations

//make sure to provide auth credentials!
var client = 
    new SodaClient("data.smgov.net", "AppToken", "[email protected]", "password");

//Upsert some data serialized as CSV
string csvData = File.ReadAllText("data.csv");
client.Upsert(csvData, SodaDataFormat.CSV, "1234-wxyz");

//Upsert a collection of serializable entities
IEnumerable<MyClass> payload = GetPayloadData();
client.Upsert(payload, "1234-wxyz");

Build

Compilation can be done using Visual Studio Community Edition.

NUnit was used to build and run the test projects. Check out the NUnit Test Adapter to run tests from within Visual Studio.

You can also use the build.cmd script, which assumes msbuild and nuget are available:

git clone [email protected]:CityofSantaMonica/SODA.NET.git SODA.NET
cd SODA.NET
.\build.cmd

To create the Nuget package artifacts, pass an extra parameter:

.\build.cmd CreatePackages

Contributing

Check out the Contributor Guidelines for more details.

Copyright and License

Copyright 2017 City of Santa Monica, CA

Licensed under the MIT License

Thank you

A tremendous amount of inspiration for this project came from the following projects. Thank you!

soda.net's People

Contributors

thekaveman avatar kevinsmgov avatar sevilturner avatar mickmorbitzer avatar allejo avatar chrismetcalf avatar

Watchers

James Cloos avatar

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.