Feed API 3.0
From NUBWiki
Contents |
Introduction
The Feed API v3.0 is a non-backwards compatible replacement of the existing v2.0. Several new parameters are added and listed next to the previous items from Feed API v3.0. Major changes include festival manipulation, multiple media, and the concept of core, searchable and enrichment. The following page will introduce these concepts in more depth as well as describing the API in full.
Events
The Feed API v3.0 is built around the concept of events. These are designed to closely match what we intuitively see an event as, something happening somewhere at sometime. While in v1.0 these three concepts where separated into productions, locations and activities respectively, v3.0 brings these into the single object - event.
Everything that is known about that event, which includes everything known about when the event is occurring and the location its occurring at, is part of the event object. For those who are used to normalized data or relationship databases, this can seem a little counter-intuitive.
If multiple events are occurring at the same location, then the location's details will be listed multiple times. Although this means the data is duplicated, the power of this de-normalization is that it is now possible to find events based on criteria related to whats happening, when its happening, and where its happening.
NUB XML
All responses from the Feed API v3.0 uses a XML format known as the NUB XML. The following is a summary of the format:
<nubxml>
<suggestion>...</suggestion>
<events start=... rows=... numfound=...>
<event eventcidn=... productioncidn=... datecreated=... datechanged=...>
...
</event>
</events>
<facets>
<facet name=... param=...>
...
</facet>
</facets>
</nubxml>
Contained in the XML are:
- #Spelling_Suggestions
- Events found by the search
- Search Facets
<a name="Searching_for_Events"></a>
Searching for Events
Searching for events is done through HTTP GET requests to a REST interface. The following is a description of the interface.
<a name="Requests"></a>Requests
Base URL: http://test.publisher.uitburo.nl/agenda/search.do
Parameters: Let op!: Alle parameters zijn hoofdlettergevoelig
Parameters:
| Parameter name | input type | Explanation | Part of | Example |
| key | xs:string | All requests must include the access key for your account. This key will be used to retrieve your account and apply any account specific filtering during searches | Core | http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725 |
| locale | xs:string | The Feed API v3.0 supports searching in multiple locales. This parameter defines both the locale for searching, and the locale for the results. Note, the search is applied against the index for the locale, so only those events which have a translation for the specified locale, will be considered. See #Locales for more information. | Core | http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&locale=fy_NL |
| start | xs:int | Defines the starting index for the current page of search results. A search can potentially result in thousands of results. Returning this all in one request would be very inefficient, therefore the Feed API requires users to 'page' through results. The start parameter, in combination with the rows parameter defined below, allows control over the page size and which page to retrieve. Note, the start value is an offset from 0, rather than a page number. | Core | Assuming the default rows of 10, to retrieve the second page of results: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&start=10 |
| rows | xs:int | Defines the number of results to return in the current request. This can be considered as the page size, and for most users it makes sense to use the same number for each request. Values in excess 1000 will take some time to respond. | Core | To define a page size of 12: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&rows=12 |
| text | xs:string | Text to query events for. This is perhaps the most important parameter, as it is used to find events and will influence their relevancy score. The value will be used to query a number of different fields in events. Case is ignored. | Searchable | To find Shakespearean events: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&text=shakespeare |
| locationText | xs:string | Text used to find events that are occurring in a certain city. Although this is a free text search like the text parameter, it does not influence the relevancy score of results. Case is ignored. | Searchable | To find events in Venlo: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&locationText=Venlo |
| location | xs:string | Exact name of a location that events must be occurring at. Here, location refers to the name of the location, such as Centrale Bibliotheek. While it is possible to include the location in the text parameter, the text parameter is a free text search. This is a filter, meaning it must match the location title of the event exactly and has no influence on relevancy scoring. The source of these values are most likely the location facet described below. Case is important. | Searchable | To find events occurring at the Centrale Bibliotheek: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&location=Centrale%20Bibliotheek |
| headGenre | xs:string | Filters the events to only those that have the head genre. Note this is a case sensitive exact match. Can be specified multiple times to select events which have head_genre_1 AND head_genre_2 AND ... head_genre_n | Searchable | To find events with the head genres Dans AND Film: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&headGenre=Dans&headGenre=Film |
| Head genre OR | To combine the Headgenre filters to form a logical operator OR, use headGenreOperatorAnd=false as parameter. | Searchable | To find events with the head genres Dans OR Film: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&headGenre=Dans&headGenre=Film&headGenreOperatorAnd=false | |
| subGenre | xs:string | Filters the events to only those that have the sub genre. Note this is a case sensitive exact match. Can be specified multiple times to select events which have sub_genre_1 OR sub_genre_2 OR sub_genre_n | Searchable | To find events with the sub genres Kamermuziek or SpeelFilm: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&subGenre=Kamermuziek&subGenre=SpeelFilm |
| period | xs:string | Named period of time which events must start during. See #Periods for a list of the named periods and what they resolve too. | Searchable | To find all events today: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&period=TODAY |
| periodStart | xs:date-timestamp Y-mm-ddThh:mm:ssZ | Defines the start of the period in which events must start during. See #Dates_.26_Times for the datetime format. | Searchable | To find all events starting after March 15 2010: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&periodStart=2010-04-15T00:00:00Z |
| periodEnd | xs:date-timestamp Y-mm-ddThh:mm:ssZ | Defines the end of the period in which events must start during. See #Dates_.26_Times for the datetime format. | Searchable | To find all events starting before September 15 2010: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&periodEnd=2010-09-15T00:00:00Z |
| gratis | xs:bit (0 or 1) | Defines whether events should be noted as gratis or not. Possible values 1 or 0. When omitted, no filtering is applied. | Searchable | To find gratis events: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&gratis=1 |
| regionId | xs:int | [depricated] Defines which region events must be occurring in (or the responsibility of). See #Regions for the list of region ids. When omitted, no region filtering is applied | Searchable | To find events in Amsterdam: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725®ionId=1 |
| lmts | xs:bit (0 or 1) | Defines whether events should have Last Minute Ticket Shop (LMTS) prices. Possible values of 1 or 0. When omitted, no filtering is applied. | Searchable | To find LMTS events: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&lmts=1 |
| changedSince | xs:date-timestamp Y-mm-ddThh:mm:ssZ | Defines that events must have changed after the given date Date. See #Dates_.26_Times for the date format. | Searchable | To find all events that have changed after March 15 2010: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&changedSince=2010-04-15T00:00:00Z |
| hasMedia | xs:bit (0 or 1) | Defines whether events should have media associated with them. Note, this is only media related to the event itself, not the location where the event is occurring. Possible values of 1 or 0. When omitted, no filtering is applied | Searchable | To find events with media: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&hasMedia=1 |
| sort | xs:string | Defines the kind of sorting that should be applied to the search results. By default, search results are sorted by their relevancy score descending, meaning the most relevant results are first. By setting this parameter, different sorting will occur. Possible values are:
| Searchable | To sort events by their title: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&sort=title |
| direction | xs:string (asc or desc) | Defines the direction of the sort specified by the sort parameter. Two possible values, "asc" for ascending, and "desc" for descending. When omitted, descending sorting is applied. | Searchable | To sort events in a descending order: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&sort=title&direction=desc |
| eventcidn | xs:string | Chooses an event with a specific event cidn. Can be specified multiple times to select multiple events. Maximum number of values that can be defined is 1024. | Searchable | To choose the event with CIDN 2009-A-001-123456: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&eventcidn=2009-A-001-123456 |
| productioncidn | xs:string | Chooses events with a specific production cidn. Can be specified multiple times to select events with different production cidns. Maximum number of values that can be defined is 1024. | Searchable | To choose events with the production CIDN 2009-P-001-123456: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&productioncidn=2009-P-001-123456 |
| locationcidn | xs:string | Chooses events with a specific location cidn. Can be specified multiple times to select events with different location cidns. Maximum number of values that can be defined is 1024. | Searchable | To choose events with the location CIDN 2009-L-001-123456: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&locationcidn=86542ae3-9c5a-413c-bd78-66e23a3096c4 |
| seed | xs:string | The seed parameter can be used to identify a randomized set. In future requests, the same set can be retrieved by using the same seed paramenter. When requesting a subset, like the first 10 items, of a randomized set, it is possible to request for the second 10 items (10 to 20) of that same randomized set. | Searchable | Seed example: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&seed=alpha |
| metaStatus | xs:string | A production is equiped with a certain metastatus. See #MetaStatus for a list. This metastatus must be one of the following options:
| Core | example: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&metaStatus=deleted |
| source | xs:string | The source of the event is considered to be a party or organisation wherefrom the author has published an event. | Core | example when search by source called alpha: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&source=alpha |
| owner | xs:string | The author of the event, who added the event from an organisation or party (source) | Core | example when searching for an owner called willem: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&owner=willem |
| type | xs:string | An event has a certain type and can be choosen as a string | Searchable | example when search for event types like Festivals: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&type=Festival |
| eventStatus | xs:string | An event has a status as well. See #EventStatus for a list.
| Searchable | example for previewing events with an eventStatus postponed: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&eventStatus=postponed |
| postalCode | xs:string | PC location | Searchable | example for searching events with postalcode 1234AB: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&postalCode=1234AB |
| locationTags | xs:string | tags for location | Searchable | example with locationTags Amsterdam: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&locationTags=Amsterdam |
| partycidn | xs:string | The cultural ID number of a certain party (e.g. hamlet, mozart) can be used to get an event | Searchable | example for previewing events with partycidn 12345: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&partycidn=12345 |
| priceTag | xs:string | The category of prices according to ticketshops | Searchable | example for showing events by priceTag: http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&priceTag=12345 |
| uitgaves | xs:string | It is possible to select by "uitgaves" (dutch for editions/publications) | Core | example for showing events by with "uitgaves" like amsterdam http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&uitgaves=Amsterdam |
| parent | xs:string | It is possible to show events by using the parent eventid | Searchable | example for previewing events by using the parentid eventid http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&parent=1234 |
| age | xs:int (range) | Events with certain age-constraints can be applied with a range from 18 to 99 | Searchable | example for showing events with an age within the range 16-21 http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&age=16:21 |
| price | xs:double (range) | A price range for events as a double. | Searchable | example for showing events with prices within the range 12.50 to 19:95 http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&price=12.50:19:95 |
| type | xs:string | The type of event you ask for. | Searchable | example for showing events that are typed to be festivals http://publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&type=Festival |
Note, events which have completed in the past cannot be requested and will not be included in the search results. Such requests will not result in an error, just an empty result list.
<a name="Examples"></a>
Examples
The following are examples of common searches:
- Find all events
GET /agenda/search.do HTTP/1.1
- Find all events involving Hamlet:
GET /agenda/search.do?text=hamlet HTTP/1.1
- Find all Dans events:
http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&headGenre=Dans
- Find all Dans events happening at Het Muziektheater Amsterdam:</li>
http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&headGenre=Dans&location=Het%20Muziektheater%20Amsterdam
- Find all events sorted by startdatetime:
http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&sort=startdatetime&direction=asc
- Find all events in Amsterdam Uitburo region:
http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725®ionId=1
Locales
The Feed API 3.0 supports multiple locales. Through the locale parameter it is possible to search for events in a specific locale. For simplicity, searches are only done on events which have a translation in the specified locale. Therefore although an event might be found when searching in nl_NL, it might not be found when searching in fy_NL. The following table defines the locales and their parameter values:
| Locale | Locale Parameter Value |
| Nederlands | nl_NL |
| Fries | fy_NL |
| English | en_US |
| French (coming soon) | fr_FR |
| German (coming soon) | de_DE |
Regions
Each event in the Feed API is assigned a specific uitgave, which connects an event to its owning Uitburo. The following table defines the uittgaves with their region ids. Region id's are used internally by NUB but is depricated, due to migration to new software:
| Region Name | Region ID |
| Netherlands (whole country) | 0 |
| Amsterdam | 1 |
| Rotterdam | 2 |
| Den Haag | 3 |
| Groningen | 4 |
| Enschede | 5 |
| Leiden | 6 |
| Maastricht | 7 |
| Limburg | 8 |
| Utrecht | 9 |
| Nijmegen | 10 |
| Noord-Holland | 11 |
| Apeldoorn | 12 |
| Friesland | 13 |
| Arnhem | 14 |
| Drenthe | 15 |
| Flevoland | 16 |
| Gelderland | 17 |
| Noord-Brabant | 18 |
| Overijssel | 19 |
| Zeeland | -- |
| Zuid-Holland | 21 |
| Zwolle | 22 |
Dates & Times
The Feed API v2.0 uses UTC for all its datetimes, in the following format: The Feed API v2.0 uses datetimes in the following format: yyyy-MM-dd'T'HH:mm:ss'Z'. See here for a description of the format.
The only exception to this is the <starttime/> element which is stored as text and is in CET time.
Some events are entered into the system without a time in their startdatetime. Such events are given the start time 06:03 CET (05:03 UTC). Equally, some events do not have enddatetimes. These events are given given the startdatetime as their enddatetime.
Periods
Periods are simple shorthand values for common date periods. The following table defines the current periods with their full date ranges: Note: The all capital names are required!
| Period | Date Range |
| TODAY | 5am Today - 5am Tomorrow |
| TOMORROW | 5am Tomorrow - 5am the following day |
| THISWEEK | 5am Today - 5am 7 days from Today |
| THISMONTH | 5am Today - 5am 31 days from Today |
| TODAYEVENING | 4pm Today - 5am Tomorrow |
| TOMORROWEVENING | 4pm Tomorrow - 5am the following day |
Periods can be used in search requests through the period parameter.
EventStatus
EventStatus is used to determine the status of a certain event.
| Normal | The status of this event is normal |
| Postponed | This event has been postponed |
| Cancelled | This event has been cancelled |
The EventStatus can be used in the search requests through the EventStatus parameter.
MetaStatus
MetaStatus is used to determine the status of a certain production.
| Name | Variable | Description |
| Active | active | This production is active |
| Deleted | deleted | This production has been deleted |
| Duplicate | duplicate | This production is considered to be duplicate |
| Incomplete | incomplete | This production is considered to be incomplete |
| Party template | party | This production uses an party template |
| Production template | production | This production uses a production template |
| Location template | location | This production uses a location template |
The MetaStatus can be used in the search requests through the metaStatus parameter.
Relevancy
At the heart of the Feed API 3.0 is the concept of search result relevancy. As opposed to a traditional relational database based system, where the order of how results are returned to the user is less important, free text search system such as the Feed API 3.0 are driven by the concept of a relevancy score. When a search is executed, a relevancy score is computed for each search result. The score is computed using Apache Lucene's academically proven algorithm which is described here: http://lucene.apache.org/java/2_9_1/api/core/index.html.
Part of the scoring algorithm is field specific boosting. This allows matches on specific fields in events to be considered more important than matches on other fields. The order of importance defined in the Feed API 3.0 is as follows:
- title
- location name
- gezelschappen
- medewerker name
- head genre
- sub genre
- summary, short description, description
Matches on combinations of these fields will be combined together when computing the final score. Therefore a match on title and head genre will be more important than just a match on title.
<a name="Search_Facets"></a>Search Facets
In addition to events, the Feed API 3.0 includes search facets. Conceptually, search facets use the categorisation of events in a search result list, to provide ways to filter the list further.
Imagine a situation where a user searches for 'Anouk' using the text parameter defined above. This will result in a wide array of events occurring at different locations. Through the location search facet, it would be possible to see how many of these events are occurring at each location. Using the location values, it would then be possible to filter the search results to see only those events happening at Amsterdam Arena, for example.
The facet information included in the Feed API 3.0 results follows the following format:
<facet name="FACET_NAME" param="FACET_PARAM"> <facetEntry count="COUNT">VALUE</facetEntry> ... </facet>
Here:
- FACET_NAME is a logical name for the facet
- FACET_PARAM defines the parameter to use in combination with VALUE to filter the search results
- COUNT defines the number of events in the total search results (not just the current page) that have the value VALUE
- VALUE is the value that the events have for the facet
Therefore assuming the following example:
<facet name="HeadGenre" param="headGenre"> <facetEntry count="240">Cabaret</facetEntry> <facetEntry count="384">Dans</facetEntry> <facetEntry count="38">Film</facetEntry> </facet>
For the facet 'HeadGenre' there exists 240 events with the value 'Cabaret', 384 with 'Dans' and 38 with 'Film'. To then filter the results to those with 'Film', you would append http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&headGenre=Film to your request. The Feed API 3.0 defines 4 facets:
- HeadGenre (based on the event head genres)
- SubGenre (based on the event sub genres)
- Location (based on the event location titles)
- Period
Spelling Suggestions
Another component of the response from the Feed API 3.0, is spelling suggestions. Included at the top of the NUBXML under the <suggestion/> tag, spelling suggestions are suggestions for new text parameter values, based on those provided in a request. Internally, the text parameter value is compared against indexed terms and a suggestion that will result in the highest number of results is generated.
Consider a search with http://test.publisher.uitburo.nl/agenda/search.do?key=a9d8fc27e5cbde7bca8402b53fe5a725&text=hamlek Such a search will most likely result in 0 results. In this situation, the Feed will suggest the correctly spelled 'hamlet' as an alternative text value. The following is the XML illustrating this example:
<nubxml> <suggestion>hamlet</suggestion> <events start="0" rows="10" numfound="0"> </events> ... </nubxml>
Note, suggestions are segregated on a per region basis. This means that when searching with the regionId=1, only those events with this region id will be used as a source of suggestions. Also, when the generated suggestion is the same as the provided text parameter value, the suggestion will not be included in the search response.
