{"id":5244,"date":"2024-05-19T21:33:04","date_gmt":"2024-05-19T21:33:04","guid":{"rendered":"https:\/\/dalelane.co.uk\/blog\/?p=5244"},"modified":"2026-04-02T18:29:38","modified_gmt":"2026-04-02T18:29:38","slug":"using-books-data-in-scratch","status":"publish","type":"post","link":"https:\/\/dalelane.co.uk\/blog\/?p=5244","title":{"rendered":"Using books data in Scratch"},"content":{"rendered":"<p><strong>In this post, I want to share a Scratch extension that I&#8217;ve been working on today: enabling access to books data from the <a href=\"https:\/\/openlibrary.org\">OpenLibrary<\/a> API through new Scratch blocks.<\/strong><\/p>\n<p>Most of the work I do on <a href=\"https:\/\/machinelearningforkids.co.uk\">Machine Learning for Kids<\/a> involves adding machine learning models into Scratch. To enable students to create interesting projects, it also helps to make it easier to get external data into Scratch that they can use for training and classifying. A few examples of where I&#8217;ve done this in the past include creating Scratch blocks to access <a href=\"https:\/\/dalelane.co.uk\/blog\/?p=4850\">weather data<\/a>, <a href=\"https:\/\/dalelane.co.uk\/blog\/?p=4766\">data from Spotify<\/a>, and <a href=\"https:\/\/dalelane.co.uk\/blog\/?p=4329\">data from Wikipedia<\/a>.<\/p>\n<h3>New blocks<\/h3>\n<p>The new blocks I&#8217;ve worked on today use the <a href=\"https:\/\/openlibrary.org\/developers\/api\">OpenLibrary API<\/a> to enable access to information about books.<\/p>\n<p><img decoding=\"async\" style=\"width: 100%; max-width: 900px; border: thin black solid\" src=\"https:\/\/images.dalelane.co.uk\/2024-05-19-openlibrary\/scratchblocks.png\"\/><\/p>\n<p><!--more--><code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Search by ISBN<\/code><\/p>\n<p>This tries to find a specific book using an International Standard Book Number.<\/p>\n<p><code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Search by title<\/code><\/p>\n<p>This tries to find a specific book using the provided title.<\/p>\n<p><code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Search by author<\/code><\/p>\n<p>This selects a random book by the provided author. Each time this block is executed, a different book will be selected.<\/p>\n<p><code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Search by subject<\/code><\/p>\n<p>This selects a random book that includes the selected subject in the categories in OpenLibrary. Each time this block is executed, a different book will be selected.<\/p>\n<p><code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Title<\/code>, <code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Author<\/code>, <code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Number of pages<\/code>, <code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Year<\/code>, <code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">ISBN<\/code><\/p>\n<p>These blocks let you use the attributes of the most recent book search result in the Scratch project.<\/p>\n<p><code style=\"background-color: #ffffc0; font-weight: 600; color: #770000;\">Add cover to costume<\/code><\/p>\n<p>This downloads a picture of the cover of the most recent book search result. It adds it as a costume to the sprite, and switches to it.<\/p>\n<h4>Try them for yourself<\/h4>\n<p>To try these blocks for yourself, you can access my fork of Scratch at <a href=\"https:\/\/machinelearningforkids.co.uk\/scratch\/\">machinelearningforkids.co.uk\/scratch<\/a>.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/raw.githubusercontent.com\/IBM\/taxinomitis\/master\/mlforkids-api\/public\/images\/scratch3-extensions.png\" style=\"width: 100%; max-width: 900px; border: thin black solid\"\/><\/p>\n<h3>Simple project<\/h3>\n<p>This means that you can do something like this: <\/p>\n<ul>\n<li>search for a random book by your favourite author<\/li>\n<li>display the details of it in your Scratch project<\/li>\n<li>switch your sprite costume to be a picture of the front cover<\/li>\n<\/ul>\n<p><img decoding=\"async\" style=\"width: 100%; max-width: 900px; border: thin black solid\" src=\"https:\/\/images.dalelane.co.uk\/2024-05-19-openlibrary\/sample-project.png\"\/><br \/><small><a href=\"https:\/\/images.dalelane.co.uk\/2024-05-19-openlibrary\/sample-project.png\" target=\"_blank\" rel=\"noopener\">open screenshot in new window<\/a><\/small><\/p>\n<h3>Machine Learning project<\/h3>\n<p>To show an example of how this could be used as part of a machine learning project, I also wrote a new worksheet for <a href=\"https:\/\/machinelearningforkids.co.uk\/worksheets\">Machine Learning for Kids<\/a>.<\/p>\n<p><a href=\"https:\/\/machinelearningforkids.co.uk\/worksheets\"><img decoding=\"async\" style=\"width: 100%; max-width: 900px; border: thin black solid\" src=\"https:\/\/images.dalelane.co.uk\/2024-05-19-openlibrary\/worksheet.png\"\/><\/a><\/p>\n<p>The instructions guide you through how to use the new Books extension to collect examples of front covers for books on a subject of your choice. It shows you how to short them into two groups:<\/p>\n<ul>\n<li>covers you like &#8211; covers that would encourage you to pick up a book, and maybe try reading it<\/li>\n<li>covers you don&#8217;t like &#8211; covers that make you think maybe that book isn&#8217;t for you<\/li>\n<\/ul>\n<p><img decoding=\"async\" style=\"width: 100%; max-width: 900px; border: thin black solid\" src=\"https:\/\/images.dalelane.co.uk\/2024-05-19-openlibrary\/training-data.png\"\/><\/p>\n<p>The instructions then explain how to use these to train a machine learning model to predict whether you will like a new book cover. <\/p>\n<p>This can be used to make a recommendation system in Scratch, that predicts what you will think of new book covers.<\/p>\n<p><iframe loading=\"lazy\" width=\"450\" height=\"270\" src=\"https:\/\/www.youtube.com\/embed\/7_rFfI7vZ1g?si=DqjGF9kx2p_Spo9Z\" title=\"YouTube video player\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\"  style=\"border: thin black solid\" allowfullscreen><\/iframe><br \/>\n<small><a href=\"https:\/\/youtu.be\/7_rFfI7vZ1g\">youtu.be\/7_rFfI7vZ1g<\/a><\/small><\/p>\n<p>If you&#8217;d like to give this a try, you can find the instructions at <a href=\"https:\/\/machinelearningforkids.co.uk\/worksheets\">machinelearningforkids.co.uk\/worksheets<\/a>.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In this post, I want to share a Scratch extension that I&#8217;ve been working on today: enabling access to books data from the OpenLibrary API through new Scratch blocks. Most of the work I do on Machine Learning for Kids involves adding machine learning models into Scratch. To enable students to create interesting projects, it [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":5245,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[587,536],"class_list":["post-5244","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-code","tag-mlforkids-tech","tag-scratch"],"_links":{"self":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5244","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=5244"}],"version-history":[{"count":2,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5244\/revisions"}],"predecessor-version":[{"id":5972,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/posts\/5244\/revisions\/5972"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=\/wp\/v2\/media\/5245"}],"wp:attachment":[{"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=5244"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=5244"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dalelane.co.uk\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=5244"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}