An easy API wrapper for Socrata API using Guzzle
- Easily intergrates with Laravel
- Chicago Service provider
in composer.json
add following in require
:
"howlowck/socrata": "dev-master"
run php artisan config:publish howlowck/socrata
then change the values according under app/config/packages/howlowck/socrata/config.php
In app/config/app.php
add the following in providers
'Howlowck\Socrata\SocrataChicagoServiceProvider',
That will load the Socrata Chicago Data Portal routes, and register the wrapper as a singleton.
Create a Socrata Instance
If you didn't use the service provider, you can easily create a Socrata instance like so:
$soc = new Howlowck\Socrata\Socrata($baseUrl, $secret_token, $public_token);
Create a Request
Without service provider (con't from above)
$request = $soc->createRequest('7as2-ds3y');
Or with service provider loaded for Chicago
$request = App::make('socrata-chicago')->createRequest('7as2-ds3y');
filter on Socrata datasource with SoQL query
You can use query keywards outlined on socrata's site as methods
$request->where('number_of_potholes_filled_on_block>3');
$request->select('zip');
simple filter
You can also run any simple filters as methods.
$req->service_request_number('11-00026951');
get Response
Response will be return as GuzzleHttp\Message\Response which then can be turned into number of formats
To get JSON from response
$response = $req->get();
$jsonResponse = $response->json();