Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

200
Views
How to get query params in fast api from POST request

Client might send multiple query params like:

# method = POST 
http://api.com?x=foo&y=bar

I need to get all the query params and extract it as a string x=foo&y=bar from the POST request.

Is there a way to do this on fast api? I could not find it on their docs.

NOTE :

We are not sure of the names of the params before hand.

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Depending how you want to use the data, you can either use request.query_params to retrieve a immutable dict with the parameters, or you can use request.url to get an object representing the actual URL. This object has a query property that you can use to get the raw string:

from fastapi import FastAPI, Request
import uvicorn

app = FastAPI()

@app.get('/')
def main(request: Request):
    return request.url.query

 
uvicorn.run(app)

This returns the given query string /?foo=123 as foo=123 from the API. There is no difference between a POST or GET request for this functionality.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!