# Making web get requests?

**URL:** <https://community.spritely.institute/t/making-web-get-requests/754>\
**Category:** Hoot: Guile in WASM\
**Tags:** help, hoot\
**Created:** [August 4, 2025, 11:27pm UTC](https://community.spritely.institute/t/making-web-get-requests/754 "2025-08-04T23:27:40Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![kryptec](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kryptec](https://community.spritely.institute/u/kryptec)\
**Post date:** [August 4, 2025, 11:27pm UTC](https://community.spritely.institute/t/making-web-get-requests/754/1 "2025-08-04T23:27:40Z")

</div>

What is the recommended way (or is there a way) to make web requests/api calls etc. within hoot.

I was hoping to make a get request in my app, and then parse the returned json. My initial idea was to use the guile web modules, but those don’t seem to be included in hoot yet.

Thanks for the help!

---

<div class="post-metadata">

**Author:** ![dthompson](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.spritely.institute/dthompson/32/95_2.png) [@dthompson](https://community.spritely.institute/u/dthompson)\
**Post date:** [August 5, 2025, 2:47pm UTC](https://community.spritely.institute/t/making-web-get-requests/754/2 "2025-08-05T14:47:47Z")

</div>

There is nothing built-in, currently. One option would be to use `(hoot ffi)` to write a binding for `fetch`.

---

<div class="post-metadata">

**Author:** ![neosloth](https://avatars.discourse-cdn.com/v4/letter/n/c57346/32.png) [@neosloth](https://community.spritely.institute/u/neosloth)\
**Post date:** [July 15, 2026, 11:05pm UTC](https://community.spritely.institute/t/making-web-get-requests/754/3 "2026-07-15T23:05:44Z")

</div>

This took me a bit of playing around to figure out so I figured I’d add an example of how I was able to implement a fetch (error handling left as an exercise for the reader, and future me)

On the host:

```js
window.addEventListener("load", async () => {
   try {
       const [proc] = await Scheme.load_main("main.wasm", {
           user_imports: {
               json: {
                   stringify: (resource) => JSON.stringify(resource),
               },
               window: {
                   fetch: async (resource) => {
                       const response = await fetch(resource);
                       const result = await response.json();
                       return result;
                   }
               },
       });
       proc.call_async();
   } catch(e) {
       if(e instanceof WebAssembly.CompileError) {
           document.getElementById("wasm-error").hidden = false;
       }
       throw e;
   }
});

```

In hoot:

```lisp
(use-modules 
             (fibers promises)
             (hoot ffi))

(define-foreign stringify
  "json" "stringify"
  (ref extern) -> (ref string))

(define-foreign fetch
  "window" "fetch"
  (ref string) -> (ref extern))

(lambda (resolved rejected)
  (call-with-async-result
   resolved rejected
   (lambda ()
     (let* ((result (await (fetch "${JSON-URL}")))
            (result-string (stringify result)))
       (format #t "~a" result-string)

```

---

<div class="post-metadata">

**Author:** ![kryptec](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kryptec](https://community.spritely.institute/u/kryptec)\
**Post date:** [September 7, 2026, 11:10pm UTC](https://community.spritely.institute/t/making-web-get-requests/754/4 "2026-09-07T23:10:32Z")

</div>

Well a year later I finally got around to making this work.

I was able to use your hints/code to fetch the wikimedia picture of the day for my puzzle game.

I’m pretty sure I didn’t do this in the best way, but it’s working! Thanks for the help!

[https://puzzled.do-ocracy.ca/](https://puzzled.do-ocracy.ca/)

---

<div class="post-metadata">

**Author:** ![alanz](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.spritely.institute/alanz/32/261_2.png) [@alanz](https://community.spritely.institute/u/alanz)\
**Post date:** [September 8, 2026, 9:03pm UTC](https://community.spritely.institute/t/making-web-get-requests/754/5 "2026-09-08T21:03:36Z")

</div>

Its great to see this back again. I can see some idle time disappearing for me

---

<div class="post-metadata">

**Author:** ![kryptec](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kryptec](https://community.spritely.institute/u/kryptec)\
**Post date:** [September 9, 2026, 7:12am UTC](https://community.spritely.institute/t/making-web-get-requests/754/6 "2026-09-09T07:12:33Z")

</div>

Happy to see it getting some use! 🙂

---

<div class="post-metadata">

**Author:** ![Nerine](https://yyz2.discourse-cdn.com/flex030/user_avatar/community.spritely.institute/nerine/32/416_2.png) [@Nerine](https://community.spritely.institute/u/Nerine)\
**Post date:** [September 25, 2026, 2:10pm UTC](https://community.spritely.institute/t/making-web-get-requests/754/7 "2026-09-25T14:10:44Z")

</div>

I just tried this, it’s lovely! I definitely see adding it to my morning routine.

Would it be OK to share the link with a few friends?

---

<div class="post-metadata">

**Author:** ![kryptec](https://avatars.discourse-cdn.com/v4/letter/k/f05b48/32.png) [@kryptec](https://community.spritely.institute/u/kryptec)\
**Post date:** [September 26, 2026, 2:44am UTC](https://community.spritely.institute/t/making-web-get-requests/754/8 "2026-09-26T02:44:22Z")

</div>

Delighted to hear! Yes, please feel free to share it with whomever you like.
