You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

3.6 KiB

🔢 🔢

🕐 👆 📣 🎏 🔢 🔢 👈 🚫 🍕🔢, 👫 🔁 🔬 "🔢" 🔢.

{* ../../docs_src/query_params/tutorial001.py hl[9] *}

🔢🔑-💲 👫 👈 🚶 ⏮️ ? 📛, 🎏 & 🦹.

🖼, 📛:

http://127.0.0.1:8000/items/?skip=0&limit=10

...🔢 🔢:

  • skip: ⏮️ 💲 0
  • limit: ⏮️ 💲 10

👫 🍕 📛, 👫 "🛎" 🎻.

🕐 👆 📣 👫 ⏮️ 🐍 🆎 (🖼 🔛, int), 👫 🗜 👈 🆎 & ✔ 🛡 ️.

🌐 🎏 🛠️ 👈 ⚖ ➡ 🔢🔢 🔢:

  • 👨‍🎨 🐕‍🦺 (🎲)
  • 💽 "✍"
  • 💽 🔬
  • 🏧 🧾

🔢

🔢 🔢 🚫 🔧 🍕 ➡, 👫 💪 📦 & 💪 ✔️ 🔢 💲.

🖼 🔛 👫 ✔️ 🔢 💲 skip=0 & limit=10.

, 🔜 📛:

http://127.0.0.1:8000/items/

🔜 🎏 🔜:

http://127.0.0.1:8000/items/?skip=0&limit=10

🚥 👆 🚶, 🖼:

http://127.0.0.1:8000/items/?skip=20

🔢 💲 👆 🔢 🔜:

  • skip=20: ↩️ 👆📛
  • limit=10: ↩️ 👈 🔢 💲

📦 🔢

🎏 🌌, 👆 💪 📣 📦 🔢 🔢, ⚒ 👫 🔢 None:

{* ../../docs_src/query_params/tutorial002.py hl[9] *}

👉 💼, 🔢 🔢 q 🔜 📦, & 🔜 None 🔢.

/// check

👀 👈 FastAPI 🙃 🥃 👀 👈🔢 item_id🔢 & q 🚫,, 🔢 🔢.

///

🔢 🔢 🆎 🛠️

👆 💪 📣 bool 🆎, & 👫 🔜 🗜:

{* ../../docs_src/query_params/tutorial003.py hl[9] *}

👉 💼, 🚥 👆 🚶:

http://127.0.0.1:8000/items/foo?short=1

⚖️

http://127.0.0.1:8000/items/foo?short=True

⚖️

http://127.0.0.1:8000/items/foo?short=true

⚖️

http://127.0.0.1:8000/items/foo?short=on

⚖️

http://127.0.0.1:8000/items/foo?short=yes

⚖️ 🙆 🎏 💼 📈 (🔠, 🥇 🔤 🔠, ️), 👆 🔢 🔜 👀 🔢 short ⏮️ bool 💲 True. False.

💗 ➡ & 🔢 🔢

👆 💪 📣 💗🔢 & 🔢 🔢 🎏 🕰, FastAPI 💭 .

& 👆 🚫 ✔️ 📣 👫 🙆 🎯 ✔.

👫 🔜 🔬 📛:

{* ../../docs_src/query_params/tutorial004.py hl[8,10] *}

🔢 🔢

🕐 👆 📣 🔢 💲 🚫-➡ 🔢 (🔜, 👥 ✔️ 🕴 👀 🔢 🔢), ⤴️ 🚫 ✔.

🚥 👆 🚫 💚 🚮 🎯 💲 ️ ⚒ 📦, ⚒ 🔢 None.

🕐 👆 💚🔢 🔢 ✔, 👆 💪 🚫 📣 🙆 🔢 💲:

{* ../../docs_src/query_params/tutorial005.py hl[6:7] *}

📥 🔢 🔢 needy🔢 🔢 🆎 str.

🚥 👆 📂 👆 🖥 📛 💖:

http://127.0.0.1:8000/items/foo-item

...🍵 🔢 needy, 👆 🔜 👀 💖:

{
    "detail": [
        {
            "loc": [
                "query",
                "needy"
            ],
            "msg": "field required",
            "type": "value_error.missing"
        }
    ]
}

needy 🚚 🔢, 👆 🔜 💪📛:

http://127.0.0.1:8000/items/foo-item?needy=sooooneedy

...👉 🔜 👷:

{
    "item_id": "foo-item",
    "needy": "sooooneedy"
}

& ↗️, 👆 💪 🔬 🔢 ✔, ✔️ 🔢 💲, & 🍕 📦:

{* ../../docs_src/query_params/tutorial006.py hl[10] *}

👉 💼, 📤 3️⃣ 🔢 🔢:

  • needy, ✔ str.
  • skip, int ⏮️ 🔢 💲 0.
  • limit, 📦 int.

/// tip

👆 💪 ⚙️ Enum🎏 🌌 ⏮️ ➡ 🔢{.internal-link target=_blank}.

///