Skip to content
Fernando Blat edited this page Apr 21, 2015 · 22 revisions

Introduction

In order to track changes in any resource (titles, metadata,…) you can use the Movida events feed.

Each entry in the feed represents a relevant event that happened on a specified resource at a specified time.

Currently, entries in the feed are generated for three types of events per resource:

  • The creation of the resource.
  • The modification of any attribute or link of the resource.
  • The deletion of the resource.

This is an example of the XML representation of the event feed:

<events type="array">
  <event>
    <id type="integer">10</id>
    <event-type>title_updated</event-type>
    <timestamp type="datetime">2013-08-14T17:09:35+02:00</timestamp>
    <changes>episode-number</changes>
    <link rel="self" href="https://movida.bebanjo.net/api/events/10"/>
    <link rel="subject" href="https://movida.bebanjo.net/api/titles/114013"/>
  </event>
  <event>
    <id type="integer">12</id>
    <event-type>title_metadata_updated</event-type>
    <timestamp type="datetime">2013-08-14T17:40:01+02:00</timestamp>
    <changes>actor,director,first-tx-starts</changes>
    <link rel="self" href="https://movida.bebanjo.net/api/events/12"/>
    <link rel="subject" href="https://movida.bebanjo.net/api/titles/59977"/>
  </event>
</events>

Available attributes:

Event ID (id)

Integer: Read only

The identifier of the event. Events are presented ordered by id and they can be filtered with the newer_than parameter (see below). You may want to store the id of the last processed event so that they don't process twice the same event.

Event Type (event-type)

String: Read only

The type of the event. The list of supported events is specified in a section below. The format of the event-type is as follows:

{{resource_type}}_{{operation}}

Currently, there are three possible operations:

  • created. For the creation of the resource.
  • updated. For the modification of any attribute or link of the resource.
  • deleted. For the deletion of the resource.

Changes (changes)

Comma-separated string: Read only

The list of attributes and links that changed. This attribute is only present if the event-type is *_update. This list refers to the names of the attributes and to the "rels" of the links of the resource that have changed. To know what are the new values for those attributes or links, you'll have to follow the subject link.

Timestamp (timestamp)

Datetime: Read only

The date and time when the event occurred.

Available links:

Subject (subject)

The resource that was created, updated or deleted.

Missing subject resource

When trying to access the subject link of the events a HTTP response code of 404 (Not Found) might be returned. It means just that the requested resource cannot be found (because it has been deleted). Probably there will be a newer event of the type *_deleted (i.e. scheduling_deleted) in the feed pending to be processed.

Getting the event feed

The event feed is linked from the root of the Movida API:

$ curl --digest -u "api_user:password" http://movida.bebanjo.net/api
<?xml version='1.0' encoding='utf-8' ?>
<movida>
  <!-- ... -->
  <link href="http://movida.bebanjo.net/api/events" rel="events"/>
</movida>

Following the events link you'll get the event feed:

$ curl --digest -u "api_user:password" http://movida.bebanjo.net/api/events
<?xml version='1.0' encoding='utf-8' ?>
<events type="array">
  <!-- ... -->
</events>

The event feed is limited to show no more than 50 events in ascending order of their timestamps (i.e. older events will appear first). You can navigate and filter the event feed using the parameters described in the following section. If the parameter newer_than is not provided, the response will contain the last 50 events in ascending order of the current account.

Available GET parameters

Newer than (newer_than)

Integer: it can be used with any other parameter

This parameter filter the feed to include only events that are newer than another one. The value of this parameter will be the id of the event taken as a reference.

For example: /api/events?newer_than=234 will return events more recent than the event 234.

Typically, you may want to store locally the id of the last event you have processed so that in the next processing you only request the events newer than the last one you processed.

Also, given that the event feed is limited to 50 entries, you should use the newer_than parameter to navigate the feed until reaching the last event.

Event type filter (event_type)

Comma-separated string: it can be used with any other parameter

This parameter will allow clients to filter the feed to include only entries for certain event types. The value of this parameter will be a list of event types separated by commas.

For example: /api/events?event_type=title_updated,title_metadata_updated will return only events whose event_type is title_updated or title_metadata_updated.

You are encouraged to use the event_type filter to fetch only those event types which are relevant to you, avoiding unnecessary processing.

Supported event types

Currently the supported event types are:

  • title_created
  • title_updated
  • title_metadata_updated
  • title_group_created
  • title_group_metadata_updated
  • scheduling_created
  • scheduling_updated
  • scheduling_deleted
  • scheduling_metadata_updated
  • publication_created
  • asset_created
  • asset_updated
  • asset_metadata_updated
  • deal_created
  • deal_updated
  • deal_deleted
  • deal_metadata_updated
  • brand_created
Clone this wiki locally