https://github.com/socrata/exsoda
tiny soda2 elixir wrapper
https://github.com/socrata/exsoda
elixir open-data socrata
Last synced: 3 months ago
JSON representation
tiny soda2 elixir wrapper
- Host: GitHub
- URL: https://github.com/socrata/exsoda
- Owner: socrata
- License: apache-2.0
- Created: 2015-06-25T20:52:38.000Z (almost 11 years ago)
- Default Branch: main
- Last Pushed: 2025-04-28T18:08:31.000Z (about 1 year ago)
- Last Synced: 2026-01-14T07:33:54.961Z (5 months ago)
- Topics: elixir, open-data, socrata
- Language: Elixir
- Homepage:
- Size: 260 KB
- Stars: 16
- Watchers: 9
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# exsoda
## What
This is a tiny wrapper for the socrata Soda2 open data API. It returns datasets as elixir streams for lazy evaluation.
## usage
```elixir
## Play around in the console
iex(1)> import Exsoda.Reader
iex(8)> with {:ok, stream} <- query("4tka-6guv", domain: "soda.demo.socrata.com") |> select([:region, :magnitude]) |> where("magnitude > 4.0") |> run do
...(8)> Enum.take(stream, 2)
...(8)> end
[[{"Region", "south of the Fiji Islands"}, {"Magnitude", 4.6}],
[{"Region", "Northern California"}, {"Magnitude", 4.4}]]
## Or elsewhere
result = query("4tka-6guv", )
|> select([:region, :magnitude])
|> where("magnitude > 4.0")
|> order("region")
|> offset(5)
|> run
with {:ok, row_stream} <- result do
Enum.take(row_stream, 10)
|> Enum.map(fn row ->
IO.inspect row
end)
end
# This will print something like the following to the console:
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "0km SE of Sakai, Japan"}, {"Magnitude", 4.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
[{"Region", "100km E of Ile Hunter, New Caledonia"}, {"Magnitude", 5.6}]
```
## Get a view
```elixir
iex(1)> import Exsoda.Reader
iex(2)> query("hcnj-rei3", domain: "data.austintexas.gov") |> get_view
{:ok,
%{"oid" => 12724312, "displayType" => "table",
"publicationAppendEnabled" => false, ...}}
```
## Running Tests Locally
The tests run using the domain cheetah.test-socrata.com .
export SOCRATA_USER=test-admin@socrata.com
export SOCRATA_PASSWORD=
./test.sh