2017 © Pedro Peláez
 

library search-v3

Cultuurnet search service for version 3

image

cultuurnet/search-v3

Cultuurnet search service for version 3

  • Monday, July 23, 2018
  • by svenhoutmeyers
  • Repository
  • 10 Watchers
  • 0 Stars
  • 937 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 3 Open issues
  • 33 Versions
  • 18 % Grown

The README.md

search-v3

This PHP library allows you to integrate with publiq's Search API3., (*1)

For legacy purposes, we also maintain a separate branch main-php7, if you need compatibility with PHP 7.4., (*2)

Full API documentation: https://docs.publiq.be/docs/uitdatabank/search-api/introduction
Getting an API key: https://platform.publiq.be, (*3)

Installation

composer require cultuurnet/search-v3

Usage

Set up a Guzzle client with a URL and API key for the test environment of Search API3 like this:, (*4)

$httpClient = new GuzzleHttp\Client([
    'base_uri' => 'https://search-test.uitdatabank.be/',
    'headers' => [
        'X-Api-Key' => 'YOUR_API_KEY_FOR_TEST_ENV',
    ],
]);

Then, set up the search-v3 SearchClient like this:, (*5)

$searchClient = new CultuurNet\SearchV3\SearchClient(
    $httpClient, // HTTP client set up in the previous step
    new CultuurNet\SearchV3\Serializer\Serializer() // Built-in serializer to deserialize the JSON responses
);

You can then perform searches like this:, (*6)

$searchQuery = new \CultuurNet\SearchV3\SearchQuery();
$events = $searchClient->searchEvents($searchQuery); // Search events
$places = $searchClient->searchPlaces($searchQuery); // Search places
$offers = $searchClient->searchOffers($searchQuery); // Search both events + places

The results are an instance of \CultuurNet\SearchV3\ValueObjects\PagedCollection, which supports the following methods:, (*7)

// Get pagination info
$events->getItemsPerPage();
$events->getTotalItems();

// Get the search results, as instances of CultuurNet\SearchV3\ValueObjects\Event
// and CultuurNet\SearchV3\ValueObjects\Place
$events->getMember()->getItems();

// Get the facet results as an instance of CultuurNet\SearchV3\ValueObjects\FacetResults
$events->getFacets();

To customize your search, you can configure \CultuurNet\SearchV3\SearchQuery like this:, (*8)

$searchQuery = new \CultuurNet\SearchV3\SearchQuery();

// Embed the JSON-LD of the search results, instead of only the ID and type.
$searchQuery->setEmbed(true);

// Set the number of which result to fetch first. Defaults to 0.
// If the first page had a limit of 30 for example, and you want to get the results of the second page, set the start to
// 30. (So the start is always the limit multiplied by the page number you want to get, starting with 0.)
$searchQuery->setStart(0);

// Set the max amount of results to return per page.
$searchQuery->setLimit(30);

// Add a sort (see SAPI3 docs for possible fields to sort on)
$searchQuery->addSort('created', 'ASC');

// Remove a sort
$searchQuery->removeSort('created');

// Add a search parameter (see src/Parameter for all options)
$searchQuery->addParameter(
    new CultuurNet\SearchV3\Parameter\AudienceType(
        CultuurNet\SearchV3\Parameter\AudienceType::AUDIENCE_EDUCATION
    )
);

// Remove a search parameter (see src/Parameter for all options)
$searchQuery->removeParameter(
    new CultuurNet\SearchV3\Parameter\AudienceType(
        CultuurNet\SearchV3\Parameter\AudienceType::AUDIENCE_EDUCATION
    )
);

Some parameters allow multiple options and can be added more than once:, (*9)

$searchQuery->addParameter(new CultuurNet\SearchV3\Parameter\Label('foo'));
$searchQuery->addParameter(new CultuurNet\SearchV3\Parameter\Label('bar'));
// Will return only results that have both labels.

The Versions

14/06 2018

dev-feature/WID-124

dev-feature/WID-124

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

08/06 2018

dev-feature/composer-dependency-fix

dev-feature/composer-dependency-fix

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

09/04 2018

dev-hotfix/WID-117

dev-hotfix/WID-117

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

27/03 2018

dev-feature/WID-109

dev-feature/WID-109

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

15/03 2018

dev-feature/WID-102

dev-feature/WID-102

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

21/02 2018

dev-feature/mkok-branch

dev-feature/mkok-branch

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

12/01 2018

dev-feature/translatable-addresses-places

dev-feature/translatable-addresses-places

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

12/01 2018

dev-feature/contactPoint-organizer

dev-feature/contactPoint-organizer

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

20/12 2017

dev-feature/III-2362

dev-feature/III-2362

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

20/12 2017

dev-feature/III-2365

dev-feature/III-2365

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

20/12 2017

dev-feature/III-2366

dev-feature/III-2366

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

08/12 2017

dev-release/guzzle-6

dev-release/guzzle-6

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

30/11 2017

dev-feature/III-2360

dev-feature/III-2360

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

30/11 2017

dev-feature/III-2356

dev-feature/III-2356

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

27/11 2017

dev-feature/WKS-343

dev-feature/WKS-343

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

27/11 2017

dev-feature/III-2353

dev-feature/III-2353

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

24/11 2017

dev-feature/III-2359

dev-feature/III-2359

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

24/11 2017

dev-feature/III-2358

dev-feature/III-2358

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

24/11 2017

dev-feature/III-2367

dev-feature/III-2367

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2368

dev-feature/III-2368

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2364

dev-feature/III-2364

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2363

dev-feature/III-2363

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2361

dev-feature/III-2361

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2357

dev-feature/III-2357

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2355

dev-feature/III-2355

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2354

dev-feature/III-2354

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2352

dev-feature/III-2352

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2350

dev-feature/III-2350

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2349

dev-feature/III-2349

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop

23/11 2017

dev-feature/III-2369

dev-feature/III-2369

Cultuurnet search service for version 3

  Sources   Download

Apache-2.0

The Requires

 

The Development Requires

by Nils Destoop