internetarchive / openlibrary

One webpage for every book ever published!
https://openlibrary.org
GNU Affero General Public License v3.0
5.26k stars 1.4k forks source link

Question about Book Search API #9576

Closed MickaeliOS closed 4 months ago

MickaeliOS commented 4 months ago

Hi everyone !

I'm a junior iOS developer working on my first project for the App Store (non profit) and I have 3 questions.

The app focuses on allowing users to search for books and add them to a personal library. To achieve a seamless user experience, I'm aiming for a search function that displays initial suggestions within like 0.4 seconds of the user typing the first letter. However, I understand the importance of optimizing API calls to avoid overwhelming the server.

I'm concerned about the scenario where a user types a single character and then stops frequently, which could result in many unnecessary API calls.

So my first question is, can I build this feature ?

As an alternative, I could implement a search function where the user types the full title and presses a dedicated "Search" button, minimizing calls to one per search.

Also, when the user add a book into his library, I wanted to store some informations, like the title, the image link, the resume, etc. on a database (CoreData or SwiftData).

My second question, you guessed it, may I store these informations ?

And my last question, do I need to download the database dump for this project or is it ok if I just make API calls ?

Thanks a lot,

Mickaël

cdrini commented 4 months ago

Hi @MickaeliOS , thank you for asking!

To answer your questions:

  1. Go for it; our APIs are there to be used, and we love it when folks can build cool things with them! Just make sure to set a User-Agent HTTP header to something we can use to identify traffic from you/your app! We monitor them regularly, so if we notice a lot of traffic from a single user agent, we will notify you.

To make this performant and not overwhelm our servers, make sure to look into best practices for implementing an auto-completing search box like this. I'm not too familiar with iOS development, but I'm sure there are built-in components that handle the details for you, but if you're building it from scratch, make sure to debounce the user's typing so that you're not making a network request for every letter typed! That should be enough to avoid overwhelming the server.

  1. Feel free to store it!

  2. I'd recommend just making the API calls. If your app becomes insanely popular it might be worth looking into saving a copy of the data dump, but I would cross that bridge when you get to it!

I hope that helps, let us know if you have any questions! Or if you hit any issues with the APIs/think of improvements to the APIs as you build your app :) And if you're building in public somewhere (eg GitHub), please post a link! Would love to follow along 😊

MickaeliOS commented 4 months ago

Thank you very much @cdrini for your complete answer, that helps me a lot !

I did not start the project yet and I can't at the moment, so I have no link sadly.

Thanks again ☺️