Skip to content

Developers

How can we help you?

← Go back

Collection Entry

A Collection Entry resource represents the link between a collection and one title.

This is how a Collection Entry resource looks like in the API:

<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <id type="integer">1</id>
  <position type="integer">1</position>
  <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/1"/>
  <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/3"/>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>
{
  "resource_type": "collection_entry",
  "id": 1,
  "position": 1,
  "self_link": "https://movida.bebanjo.net/api/collection_entries/1",
  "collection_link": "https://movida.bebanjo.net/api/title_groups/3",
  "title_link": "https://movida.bebanjo.net/api/titles/1"
}

Please, refer to the title_groups and title for more information.

Collection entry attributes

  • id (required): BeBanjo’s internal identifier for a collection entry. It must not be supplied in the creation of the collection entry, it will be set automatically.
  • position (optional): The position of this collection entry within the list of collection entries of a collection. The value, if provided, must be an integer value greater than zero. And if not provided, it will be automatically assigned to the next available position starting on 1. Trying to set a value greater than the next available position is not possible.

Get the list of collection entries of a collection

To return a (paginated) list of the collection entries for a collection, you can just follow the “collection_entries” link in a collection resource. For example, you could issue a GET request like the following:

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/title_groups/1/collection_entries
$ curl --digest -u robot_user:password -H "Accept: application/json" https://movida.bebanjo.net/api/title_groups/1/collection_entries
<?xml version="1.0" encoding="UTF-8"?>
<collection-entries type="array">
  <total-entries>2</total-entries>
  <collection-entry>
    <id type="integer">1</id>
    <position type="integer">1</position>
    <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/1"/>
    <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/1"/>
    <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
  </collection-entry>
  <collection-entry>
    <id type="integer">3</id>
    <position type="integer">2</position>
    <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/3"/>
    <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/1"/>
    <link rel="title" href="https://movida.bebanjo.net/api/titles/2"/>
  </collection-entry>
</collection-entries>
{
  "total_entries": 2,
  "entries": [
    {
      "resource_type": "collection_entry",
      "id": 1,
      "position": 1,
      "self_link": "https://movida.bebanjo.net/api/collection_entries/1",
      "collection_link": "https://movida.bebanjo.net/api/title_groups/1",
      "title_link": "https://movida.bebanjo.net/api/titles/1"
    },
    {
      "resource_type": "collection_entry",
      "id": 3,
      "position": 2,
      "self_link": "https://movida.bebanjo.net/api/collection_entries/3",
      "collection_link": "https://movida.bebanjo.net/api/title_groups/1",
      "title_link": "https://movida.bebanjo.net/api/titles/2"
    }
  ]
}

Note: This is a paginated resource. By default, only 50 collection entries will be included in each page but you can override this default by using the per_page parameter described in the next section. The total-entries attribute will indicate the total number of entries and the links rel="next" and rel="prev" should be used to get the next and the previous pages.

Valid attributes

  • per_page: Number of elements returned in each page. The maximum value allowed is 200 and the default is 50.

Get a specific collection

This operation allows you to recover information about one specific collection:

$ curl --digest -u robot_user:password https://movida.bebanjo.net/api/collection_entries/1
$ curl --digest -u robot_user:password -H "Accept: application/json" https://movida.bebanjo.net/api/collection_entries/1
<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <id type="integer">1</id>
  <position type="integer">1</position>
  <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/1"/>
  <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/3"/>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>
{
  "resource_type": "collection_entry",
  "id": 1,
  "position": 1,
  "self_link": "https://movida.bebanjo.net/api/collection_entries/1",
  "collection_link": "https://movida.bebanjo.net/api/title_groups/3",
  "title_link": "https://movida.bebanjo.net/api/titles/1"
}

Crediting a collection entry on a collection

To associate an existing title you just have to POST a payload like the following to the “collection_entries” link of any collection. Let’s suppose we want to add Forrest Gump (title with id 4 in our example):

$ cat new_collection_entry_existing_title.xml
$ cat new_collection_entry_existing_title.json
<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>
{
  "title_link": "https://movida.bebanjo.net/api/titles/1"
}
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X POST -d @new_collection_entry_existing_title.xml "https://movida.bebanjo.net/api/title_groups/4/collection_entries"
$ curl --digest -u robot_user:password -H "Content-Type: application/json" -H "Accept: application/json" -X POST -d @new_collection_entry_existing_title.json "https://movida.bebanjo.net/api/title_groups/4/collection_entries"

BeBanjo will then return the full XML/JSON of our brand new collection entry, as usual:

<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <id type="integer">1</id>
  <position type="integer">1</position>
  <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/1"/>
  <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/4"/>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>
{
  "resource_type": "collection_entry",
  "id": 1,
  "position": 1,
  "self_link": "https://movida.bebanjo.net/api/collection_entries/1",
  "collection_link": "https://movida.bebanjo.net/api/title_groups/4",
  "title_link": "https://movida.bebanjo.net/api/titles/1"
}

Updating a collection

You can update a collection entry just by issuing a PUT request to each collection entry URI. You only need to include those attributes that you wish to update:

$ cat collection_entry_update.xml
$ cat collection_entry_update.json
<collection-entry>
  <position>10</position>
</collection-entry>
{
  "position": 10
}
$ curl --digest -u robot_user:password -H "Content-Type: application/xml" -X PUT -d @collection_entry_update.xml "https://movida.bebanjo.net/api/collection_entries/2"
$ curl --digest -u robot_user:password -H "Content-Type: application/json" -H "Accept: application/json" -X PUT -d @collection_entry_update.json "https://movida.bebanjo.net/api/collection_entries/2"

As always, BeBanjo will return the full XML/JSON of the resource just updated:

<?xml version="1.0" encoding="UTF-8"?>
<collection-entry>
  <id type="integer">2</id>
  <position type="integer">10</position>
  <link rel="self" href="https://movida.bebanjo.net/api/collection_entries/2"/>
  <link rel="collection" href="https://movida.bebanjo.net/api/title_groups/4"/>
  <link rel="title" href="https://movida.bebanjo.net/api/titles/1"/>
</collection-entry>
{
  "resource_type": "collection_entry",
  "id": 2,
  "position": 10,
  "self_link": "https://movida.bebanjo.net/api/collection_entries/2",
  "collection_link": "https://movida.bebanjo.net/api/title_groups/4",
  "title_link": "https://movida.bebanjo.net/api/titles/1"
}

Deleting a collection entry

You can also delete a collection entry by sending a DELETE request to each collection entry URI:

$ curl --digest -u robot_user:password -X DELETE "https://movida.bebanjo.net/api/collection_entries/4"
$ curl --digest -u robot_user:password -H "Accept: application/json" -X DELETE "https://movida.bebanjo.net/api/collection_entries/4"