Heads Up! The ability to modify a dataset requires special permissions.
The SODA Producer API allows you to directly retrieve, modify, and delete individual rows in a Socrata dataset, using their row identifiers.
Please note that all operations that modify datasets must be authenticated as a user who has access to modify that dataset and may optionally include an application token.
With the SODA Producer API, you will be able to:
Bulk updates are also possible via our
upsert update method.
To create a single row, we’re going to do a “mini-
upsert” with only a single row. If you have a row identifier configured on your dataset, you’ll want to make sure your new row is entirely new, including the row identifier, otherwise you’ll update an existing row!
Like all SODA Producer API requests, you’ll want to make sure you’re:
Content-Typeheader, in this case
In this example, we’ll be formatting our new row as a single JSON object, wrapped in an array, like this:
Now we’ll take that payload and pass it as our payload in a
POST request to the dataset’s API endpoint:
You’ll get back a response detailing what went right or wrong:
From the response payload, you’ll be able to tell if you created a new row (
Rows Created) or updated an existing one with the same id (
Before we get into how to update rows, let’s review how you access individual rows. To use a row identifier to look up a row, simply append it to the resource endpoint for that dataset. For example, to look up row
row-evac~sxbs~gm8t from our dataset using its internal row identifier:
The server will respond with a single row:
In the next step, we’ll update that row.
To update our individual row, we’re going to do a “mini-
upsert” like we did to create a row, except this time we’re going to include an ID. For this example, we’re using the internal Socrata identifier for the row. If you have a row identifier custom-configured from your dataset, you can use that field instead of including the “
Our payload will look similar, but this time we’re going to include the
:id and change his status to “ACTIVE”:
We’ll send that via a
POST, just like we did above:
If things go well, you’ll get back a report from the server notifying you that your row has been updated:
In the next section, we’ll delete the row we’ve been experimenting with.
Deleting a single row is simple, using the
DELETE HTTP method. We’ll do the same as we did to
GET the record, but in this time we’ll use
If that row can be found, the server will respond with a
200 OK and the row will be deleted.
Got a lot of changes to make? All of these operations can be performed within a single request using upsert.