# How to get a list of query parameters of request using web-server/http/request-structs

**URL:** https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627
**Category:** Questions & Answers
**Created:** [March 15, 2025, 8:16pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627 "2025-03-15T20:16:42Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![rvdalen](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@rvdalen](https://racket.discourse.group/u/rvdalen)
#### Post date: [March 15, 2025, 8:16pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/1 "2025-03-15T20:16:42Z")

</div>

I am trying to get my head around writing simple web applications in Racket.

How do I get a list of query parameters sent as part of the request from the request struct, assuming the servlet below:

```scheme
(define (first-page request)
  ; The line below prints all the bindings, but I would like to find only the 
  ; binding:form values that were sent through url query string.
  (println (request-bindings/raw request)) ; <- this prints all the bindings
  (http-response-str "<h1>This is the first page!</h1>"))

```

TIA  
Rouan

---

<div class="post-metadata">

### Author: ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)
#### Post date: [March 15, 2025, 9:23pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/2 "2025-03-15T21:23:42Z")

</div>

I have a front-end which [sends requests using URLSearchParams](https://github.com/benknoble/frosthaven-manager/blob/43cbb8cd7d997d5bda463a34bf979bbefe0a23d0/server.rkt#L1078), and then [extracts them with request-bindings](https://github.com/benknoble/frosthaven-manager/blob/43cbb8cd7d997d5bda463a34bf979bbefe0a23d0/server.rkt#L1113). Idk if that gives you the separation you want, however; a quick test shows that my bindings come in as binding:form values.

(I do wish the docs offered alternatives for what they consider to be broken bindings extractors in section 4.2 Bindings of the Web Applications document.)

---

<div class="post-metadata">

### Author: ![damien\_mattei](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/damien_mattei/32/2706_2.png) [@damien\_mattei](https://racket.discourse.group/u/damien_mattei)
#### Post date: [March 16, 2025, 12:22am UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/3 "2025-03-16T00:22:53Z")

</div>

> [@benknoble](#):
>
> I have a front-end which sends requests using URLSearchParams, and then extracts them with request-bindings.

Hello @benknoble ,  
seems your links are broken (no URL and i can not clik on them) even if they display in blue. (or something wrong somewhere?) 🤔  
Regards,  
Damien

---

<div class="post-metadata">

### Author: ![soegaard](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/soegaard/32/19_2.png) [@soegaard](https://racket.discourse.group/u/soegaard)
#### Post date: [March 16, 2025, 12:24pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/4 "2025-03-16T12:24:58Z")

</div>

Is it the post data you are after?

 ![image](https://global.discourse-cdn.com/free1/uploads/racket/original/2X/2/258adc5da691ccecbaefbe7b7209b4cece86a0ac.jpeg)

---

<div class="post-metadata">

### Author: ![rvdalen](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@rvdalen](https://racket.discourse.group/u/rvdalen)
#### Post date: [March 16, 2025, 3:58pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/5 "2025-03-16T15:58:40Z")

</div>

Not the post data.

Data from the query parameters:

```scheme
http://localhost/first-page?name=rvd
                           ^^^^^^^^^

```

I do get a binding:form value of `(binding:form #"name" #"rvd")` by using the code:

```scheme
(request-bindings/raw request)

```

But if I send some data using query parameters, and some data in the body with a POST request, everything ends up as binding forms with no way of distinguishing which values came from POST data and which came from query parameters.

The other issue as @benknoble mentioned is that the docs tell us about a couple of binding functions ([4&nbsp;HTTP: Hypertext Transfer Protocol](https://docs.racket-lang.org/web-server/http.html#%28part._bindings%29)) and then recommend that we don't use them but the docs do not tell us what the alternative is.

---

<div class="post-metadata">

### Author: ![bogdan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/bogdan/32/8_2.png) [@bogdan](https://racket.discourse.group/u/bogdan)
#### Post date: [March 16, 2025, 4:06pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/6 "2025-03-16T16:06:20Z")

</div>

If you want just the query params in that case, you should be able to get them off of the `request-uri`.

---

<div class="post-metadata">

### Author: ![rvdalen](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@rvdalen](https://racket.discourse.group/u/rvdalen)
#### Post date: [March 16, 2025, 4:17pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/7 "2025-03-16T16:17:05Z")

</div>

Thanks @bogdan,

I guess I could do that. I can roll my own functions to use the `request-uri` to figure out which bindings are from the query parameters of the url and which bindings are POST bindings.

There is an edge case where it is possible to send the same key through POST and query parameters in the same request and both bindings show up with the same key. Now they are a bit harder to distinguish.

I guess I just expected what I am trying to do to be basic stuff built into the web server libraries from the start so I do not have to roll my own 🙂

---

<div class="post-metadata">

### Author: ![bogdan](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/bogdan/32/8_2.png) [@bogdan](https://racket.discourse.group/u/bogdan)
#### Post date: [March 16, 2025, 7:01pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/8 "2025-03-16T19:01:28Z")

</div>

Sorry, I'm not sure I follow. The `url` struct you receive from `request-uri` will only contain the query params (and their values) sent in the URL. The bindings you get from `request-post-data/raw` will contain only the urlencoded data sent as the body of the request. So, you can exactly distinguish between body data and URI params by using those two fields. The `request-bindings/raw` field merges them because that's often pretty convenient. I agree that the APIs exposed here are not ideal (and I have [my own](https://docs.racket-lang.org/koyo/http.html) helpers for this and related use cases), though.

---

<div class="post-metadata">

### Author: ![rvdalen](https://avatars.discourse-cdn.com/v4/letter/r/b4bc9f/32.png) [@rvdalen](https://racket.discourse.group/u/rvdalen)
#### Post date: [March 16, 2025, 8:21pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/9 "2025-03-16T20:21:19Z")

</div>

Ok, I had a look at `request-post-data/raw`. But it just gives me the unparsed key/values as a single stringy value. Where I could get separate key/value pairs from the bindings, which is more convenient 🙂

So lets say I send some data through post:

```scheme
curl -d 'name=rvd&filter=y' -X POST http://localhost:8000/first

```

If I go through the bindings I get the separate key/value pairs. Noice 🙂

```scheme
(request-bindings/raw request)
; => (list (binding:form #"name" #"rvd")
; (binding:form #"filter" #"y"))

```

If I look at the post-data, I get back that 1 stringy value and would have to do the parsing myself:

```scheme
(request-post-data/raw request)
; => #"name=rvd&filter=y"

```

@bogdan thanks for the link to koyo. That looks super interesting. Will have a look at that.

I guess the answers so far are:

- use bindings if you don't have to care where the data comes from.
- If you specifically want to look at URL query params or POST data, the data is there but process it yourself by writing some helper functions.

---

<div class="post-metadata">

### Author: ![benknoble](https://yyz2.discourse-cdn.com/free1/user_avatar/racket.discourse.group/benknoble/32/16_2.png) [@benknoble](https://racket.discourse.group/u/benknoble)
#### Post date: [March 16, 2025, 9:06pm UTC](https://racket.discourse.group/t/how-to-get-a-list-of-query-parameters-of-request-using-web-server-http-request-structs/3627/10 "2025-03-16T21:06:28Z")

</div>

> [@damien\_mattei](#):
>
> > [@benknoble](#):
> >
> > I have a front-end which sends requests using URLSearchParams, and then extracts them with request-bindings.
> 
> Hello @benknoble ,  
> seems your links are broken (no URL and i can not clik on them) even if they display in blue. (or something wrong somewhere?) 🤔  
> Regards,  
> Damien

Thanks for pointing this out—Discourse ate the Markdown syntax in my email and tried to create "nested links" (like `[my link text]([the-actual-link](the-actual-link))`), which clearly don't work.

I've corrected the OP; mailing list readers may want to visit to see where the links go 😅
