Bug 33146 - Add public GET endpoint for listing items
Summary: Add public GET endpoint for listing items
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: REST API (show other bugs)
Version: Main
Hardware: All All
: P5 - low new feature (vote)
Assignee: Martin Renvoize
QA Contact:
URL:
Keywords:
Depends on: 23667
Blocks: 30979 31789
  Show dependency treegraph
 
Reported: 2023-03-06 11:04 UTC by Martin Renvoize
Modified: 2023-12-28 20:43 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
23.05.00


Attachments
Bug 33146: Add public items lookup route (4.13 KB, patch)
2023-03-06 11:08 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33146: Unit tests (5.80 KB, patch)
2023-03-06 14:25 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33146: Add public items lookup route (4.06 KB, patch)
2023-03-06 14:25 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 33146: Unit tests (5.85 KB, patch)
2023-03-07 16:40 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 33146: Add public items lookup route (4.12 KB, patch)
2023-03-07 16:40 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 33146: Unit tests (5.91 KB, patch)
2023-03-31 08:20 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 33146: Add public items lookup route (4.18 KB, patch)
2023-03-31 08:20 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 33146: (QA follow-up) Do not delete all items in test (4.00 KB, patch)
2023-03-31 08:20 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 33146: Allow embedding expanded coded values (1.05 KB, patch)
2023-03-31 08:32 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 33146: (QA follow-up) Consistency with /biblios/:biblio_id/items (1.07 KB, patch)
2023-03-31 08:41 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 33146: Unit tests (5.96 KB, patch)
2023-03-31 10:20 UTC, Nick Clemens
Details | Diff | Splinter Review
Bug 33146: Add public items lookup route (9.64 KB, patch)
2023-03-31 10:20 UTC, Nick Clemens
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Martin Renvoize 2023-03-06 11:04:53 UTC
It would be helpful to have a pre-filtered public endpoint for fetching and listing items.
Comment 1 Martin Renvoize 2023-03-06 11:08:06 UTC
Created attachment 147781 [details] [review]
Bug 33146: Add public items lookup route

This patch adds a /public equivilent to the item listing endpoint.

This allows us to search for an item by it's external_id (barcode).

Test plan
1. Apply patch
2. Perform a GET on /api/v1/public/items?external_id=some_barcode
3. Confirm that the above endpoint correctly returns items that should
   be visible in the OPAC
Comment 2 Martin Renvoize 2023-03-06 14:25:17 UTC
Created attachment 147786 [details] [review]
Bug 33146: Unit tests
Comment 3 Martin Renvoize 2023-03-06 14:25:20 UTC
Created attachment 147787 [details] [review]
Bug 33146: Add public items lookup route

This patch adds a /public equivilent to the item listing endpoint.

This allows us to search for an item by it's external_id (barcode).

Test plan
1. Apply patch
2. Perform a GET on /api/v1/public/items?external_id=some_barcode
3. Confirm that the above endpoint correctly returns items that should
   be visible in the OPAC
Comment 4 Lucas Gass 2023-03-07 16:40:31 UTC
Created attachment 147863 [details] [review]
Bug 33146: Unit tests

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 5 Lucas Gass 2023-03-07 16:40:33 UTC
Created attachment 147864 [details] [review]
Bug 33146: Add public items lookup route

This patch adds a /public equivilent to the item listing endpoint.

This allows us to search for an item by it's external_id (barcode).

Test plan
1. Apply patch
2. Perform a GET on /api/v1/public/items?external_id=some_barcode
3. Confirm that the above endpoint correctly returns items that should
   be visible in the OPAC

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 6 Katrin Fischer 2023-03-07 23:03:27 UTC
I seem to remember a lot of discussion on another bug about a public endpoint for items. There are a lot of fields with information libraries might not want to make publicly available. 

I see items itself are filtered by visibility, but what about columns? Internal note, vendor and price information, materials (pref driven)?
Comment 7 Katrin Fischer 2023-03-07 23:04:16 UTC
And for locations and similar - is only the OPAC description made visible publicly?
Comment 8 Tomás Cohen Arazi 2023-03-08 00:46:23 UTC
There's a trick going on with the allow list of attributes for the public API. For authorized value expansion, see bug 33161 for how we will implement that bit
Comment 9 Martin Renvoize 2023-03-08 07:06:42 UTC
As Tomas states, we are working on the `+strings` embed part of this distinctly, and I don't attempt to handle the additional subfields Marc stuff deliberately for this reason.

We also already agreed on the public fields include back in bug 27358 where we introduced the first 'public_read_list' implementation.

Hope that settles your nerves a bit Katrin.. this is of course rather important to get right.

This is also a somewhat simpler case as it's a direct endpoint rather than an embed which has its own additional complications.
Comment 10 Katrin Fischer 2023-03-08 08:26:34 UTC
All ok, better to ask than to be sorry. :) I am glad you got it all handled and didn't remember we had finished bug 27358.
Comment 11 Nick Clemens 2023-03-30 13:52:29 UTC
The tests here die if you have any issues in your system. Can we remove the delete, and add a common attribute to the newly created items that we can use to query and limit the data set?
Comment 12 Tomás Cohen Arazi 2023-03-30 13:55:01 UTC
(In reply to Nick Clemens from comment #11)
> The tests here die if you have any issues in your system. Can we remove the
> delete, and add a common attribute to the newly created items that we can
> use to query and limit the data set?

What I always do is generating a few items, and generate a

my $query = { itemnumber => [ $item_1->id, ..., $item_n->id ] };

and then:

$t->get_ok( '...?q=' . $query );
Comment 13 Tomás Cohen Arazi 2023-03-31 08:20:13 UTC
Created attachment 149014 [details] [review]
Bug 33146: Unit tests

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 14 Tomás Cohen Arazi 2023-03-31 08:20:16 UTC
Created attachment 149015 [details] [review]
Bug 33146: Add public items lookup route

This patch adds a /public equivilent to the item listing endpoint.

This allows us to search for an item by it's external_id (barcode).

Test plan
1. Apply patch
2. Perform a GET on /api/v1/public/items?external_id=some_barcode
3. Confirm that the above endpoint correctly returns items that should
   be visible in the OPAC

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 15 Tomás Cohen Arazi 2023-03-31 08:20:18 UTC
Created attachment 149016 [details] [review]
Bug 33146: (QA follow-up) Do not delete all items in test

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 16 Tomás Cohen Arazi 2023-03-31 08:32:58 UTC
Created attachment 149017 [details] [review]
Bug 33146: Allow embedding expanded coded values

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 17 Tomás Cohen Arazi 2023-03-31 08:41:51 UTC
Created attachment 149019 [details] [review]
Bug 33146: (QA follow-up) Consistency with /biblios/:biblio_id/items

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 18 Nick Clemens 2023-03-31 10:20:51 UTC
Created attachment 149024 [details] [review]
Bug 33146: Unit tests

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 19 Nick Clemens 2023-03-31 10:20:55 UTC
Created attachment 149025 [details] [review]
Bug 33146: Add public items lookup route

This patch adds a /public equivilent to the item listing endpoint.

This allows us to search for an item by it's external_id (barcode).

Test plan
1. Apply patch
2. Perform a GET on /api/v1/public/items?external_id=some_barcode
3. Confirm that the above endpoint correctly returns items that should
   be visible in the OPAC

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Bug 33146: (QA follow-up) Do not delete all items in test

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Bug 33146: Allow embedding expanded coded values

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Bug 33146: (QA follow-up) Consistency with /biblios/:biblio_id/items

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>

Bug 33146: (QA follow-up) Make sure public API enabled for tests

Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Comment 20 Tomás Cohen Arazi 2023-03-31 10:38:30 UTC
Pushed to master for 23.05.

Nice work everyone, thanks!
Comment 21 Matt Blenkinsop 2023-04-11 11:28:05 UTC
Enhancement - not backporting to 22.11.x

Nice work everyone!