CSM.SodaDotNet.Utilities
0.10.1
Library of helper classes and extension methods for working with Socrata Open Data portals.
Install-Package CSM.SodaDotNet.Utilities -Version 0.10.1
dotnet add package CSM.SodaDotNet.Utilities --version 0.10.1
<PackageReference Include="CSM.SodaDotNet.Utilities" Version="0.10.1" />
paket add CSM.SodaDotNet.Utilities --version 0.10.1
#r "nuget: CSM.SodaDotNet.Utilities, 0.10.1"
SODA.NET 
A Socrata Open Data API (SODA) client library targeting .NET 4.5 and above.
Getting Started
SODA.NET is available as a NuGet package.
dotnet add 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", "user@domain.com", "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");
Note: This library supports writing directly to datasets with the Socrata Open Data API. For write operations that use
data transformations in the Socrata Data Management Experience (the user interface for creating datasets), use the Socrata
Data Management API. For more details on when to use SODA vs the Socrata Data Management API, see the
Data Management API documentation
Build
Compilation can be done using
Visual Studio Community Edition.
You can also use the .NET CLI:
git clone git@github.com:CityofSantaMonica/SODA.NET.git SODA.NET
cd SODA.NET
dotnet build
Tests
NUnit was used to build and run the test projects.
Run tests from the Visual Studio Test Explorer, or using the .NET CLI:
dotnet test
Contributing
Check out the Contributor Guidelines
for more details.
Copyright and License
Copyright 2019 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!
- Octokit.net
- soda-java
- soda-dotnet (defunct?)
SODA.NET 
A Socrata Open Data API (SODA) client library targeting .NET 4.5 and above.
Getting Started
SODA.NET is available as a NuGet package.
dotnet add 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", "user@domain.com", "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");
Note: This library supports writing directly to datasets with the Socrata Open Data API. For write operations that use
data transformations in the Socrata Data Management Experience (the user interface for creating datasets), use the Socrata
Data Management API. For more details on when to use SODA vs the Socrata Data Management API, see the
Data Management API documentation
Build
Compilation can be done using
Visual Studio Community Edition.
You can also use the .NET CLI:
git clone git@github.com:CityofSantaMonica/SODA.NET.git SODA.NET
cd SODA.NET
dotnet build
Tests
NUnit was used to build and run the test projects.
Run tests from the Visual Studio Test Explorer, or using the .NET CLI:
dotnet test
Contributing
Check out the Contributor Guidelines
for more details.
Copyright and License
Copyright 2019 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!
- Octokit.net
- soda-java
- soda-dotnet (defunct?)
Dependencies
-
.NETFramework 4.5
- CSM.SodaDotNet (>= 0.10.1)
- ExcelDataReader (>= 3.6.0)
- ExcelDataReader.DataSet (>= 3.6.0)
- Microsoft.CSharp (>= 4.5.0)
- Microsoft.Exchange.WebServices (>= 2.2.0)
-
.NETStandard 2.0
- CSM.SodaDotNet (>= 0.10.1)
- ExcelDataReader (>= 3.6.0)
- ExcelDataReader.DataSet (>= 3.6.0)
- Microsoft.CSharp (>= 4.5.0)
- Microsoft.Exchange.WebServices.NETStandard (>= 1.1.3)
- System.Text.Encoding.CodePages (>= 4.5.1)
Used By
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version History
Version | Downloads | Last updated | |
---|---|---|---|
0.10.1 | 338 | 10/15/2019 | |
0.9.0 | 254 | 7/24/2019 | |
0.8.0 | 747 | 12/7/2017 | |
0.7.0 | 740 | 1/12/2017 | |
0.6.0 | 807 | 6/2/2016 | |
0.5.0 | 913 | 8/12/2015 | |
0.4.1 | 781 | 6/11/2015 | |
0.4.0 | 751 | 5/7/2015 | |
0.3.0 | 818 | 1/8/2015 | |
0.2.1 | 863 | 12/2/2014 | |
0.2.0 | 1,339 | 11/3/2014 | |
0.1.2 | 833 | 10/1/2014 | |
0.1.1 | 844 | 9/16/2014 | |
0.1.0 | 852 | 8/28/2014 |