-
-
Notifications
You must be signed in to change notification settings - Fork 13
Fetching a Dataset
There are two main objects that are required in order to interact with the Socrata API: the client and the dataset object.
The SodaClient is used to handle and store the information needed to call the Socrata API such as the domain, tokens, and credentials.
$sc = new SodaClient($url, $token = "", $email = "", $password = "")
-
$url
The minimum a SodaClient requires is the domain of the API endpoint; just the domain -
$token
In order to reduce throttling, applications should have tokens -
$email
Some actions, such as writing datasets or accessing private datasets, require authentication -
$password
...and the password for the authentication
Fetching the OAuth2.0 token is not handled by the PhpSoda library but passing the token to Socrata in API calls is supported with SodaClient::setOAuth2Token()
.
$sc->setOAuth2Token("<token>");
The SodaData is used to interact with a dataset and it requires a SodaClient instance in order to make the API calls.
$ds = new SodaDataset($sodaClient, $resourceID);
-
$sodaClient
A SodaClient object which contains all of the information about the API endpoint and the credentials to use, if any, to access that dataset -
$resourceID
The 4x4 unique identifier for your dataset; it's the thing that looks likepkfj-5jsd
Here's an example of how to retrieve a dataset.
$sc = new SodaClient("opendata.socrata.com");
$ds = new SodaDataset($sc, "pkfj-5jsd");
$results = $ds->getDataset();
Found an issue? Something not clear? Submit an issue to let us know!