-
-
Notifications
You must be signed in to change notification settings - Fork 13
Writing to a Dataset
In order to take advantage of the write abilities of this library, you must create a SodaClient object that has all of the authentication credentials given.
The Socrata Open Data API has an upsert ability where you can add, delete, and update your dataset all with a single payload.
To create your payload, it could be as an associative array or a JSON encoded string.
$dataset = array(
array(
"item_id" => "1",
":deleted" => true
),
array(
"item_id" => "2",
"name" => "Update my name"
),
array(
"item_id" => "3",
"name" => "A new item",
"price" => 4
"description" => "pocket bacon"
)
);
// $ds is an instance of a SodaDataset object
$ds->upsert($dataset);
The Socrata Open Data API has a replace ability where you can replace an entire dataset with a new dataset in a single request.
You may create your payload as an associative array or a JSON encoded string.
$dataset = array(
array(
"item_id" => "1",
"name" => "Plane Text",
"price" => 10
"description" => "it's a bird"
),
array(
"item_id" => "2",
"name" => "Silver Pen",
"price" => 2
"description" => "I write in red"
),
array(
"item_id" => "3",
"name" => "Goof Item",
"price" => 4
"description" => "pocket bacon"
)
);
// $ds is an instance of a SodaDataset object
$ds->replace($dataset);
The Socrata Open Data API writes directly to your Socrata dataset. As such, it is fast and efficient. However, this differs from the default publishing workflow on the platform (creating drafts, staging data, then publishing) by not taking advantage of the on-platform data transformations available in the default publishing cycle. To support any data transformations you have running on your dataset for all future updates, look to the Data Management API.
Found an issue? Something not clear? Submit an issue to let us know!