Query parameters are key-value pairs appended to a URL after a question mark:
```
https://apilearn.tukas.dev/api/products/?category=kitchen&ordering=price
```
They let the server know what you want — which category, which page, how to sort. You could build this string yourself, but the requests library gives you a cleaner way: pass a dict as the params argument and it handles the encoding for you:
```python
import requests
BASE_URL = 'https://apilearn.tukas.dev'
params = {
'category': 'kitchen',
'ordering': 'price',
}
response = requests.get(f'{BASE_URL}/api/products/', params=params)
print(response.url) # shows the full URL that was sent
```
response.url is useful for debugging — it shows the exact URL the library built, including all encoded parameters.
The /api/products/ endpoint accepts these parameters:
- category — filter by category slug (e.g. 'kitchen', 'bedroom')
- ordering — sort field; prefix with - for descending (e.g. 'price', '-price', 'name')
- search — full-text search in product names and descriptions
- min_price / max_price — price range filter
- has_discount — set to 'true' to return only discounted products
- page / page_size — pagination (covered in the Pagination topic)
Parameters can be combined freely. The server applies all filters together, so you can ask for bedroom products under $200 sorted by name in one request.
Filter by a single category:
```python
response = requests.get(f'{BASE_URL}/api/products/', params={'category': 'office'})
data = response.json()
print(data['count']) # products in the office category only
```
Filter by price range:
```python
params = {'min_price': 50, 'max_price': 150}
response = requests.get(f'{BASE_URL}/api/products/', params=params)
for product in response.json()['results']:
print(product['name'], product['sell_price'])
```
Sort by price descending (most expensive first):
```python
params = {'ordering': '-price', 'page_size': 5}
response = requests.get(f'{BASE_URL}/api/products/', params=params)
for p in response.json()['results']:
print(p['name'], p['price'])
```
Search by keyword:
```python
params = {'search': 'chair'}
response = requests.get(f'{BASE_URL}/api/products/', params=params)
print(response.json()['count'], 'products match')
```
Combine multiple filters in one request:
```python
params = {
'category': 'bedroom',
'max_price': 300,
'has_discount': 'true',
'ordering': 'name',
}
response = requests.get(f'{BASE_URL}/api/products/', params=params)
data = response.json()
print(f'{data["count"]} discounted bedroom products under $300')
```
Note that has_discount takes the string 'true', not the Python boolean True. Query parameters are always strings in HTTP — requests converts simple values, but it is safest to be explicit with boolean-like flags.
Query parameters for GET /api/products/:
```
category string Category slug: kitchen, bedroom, living-room, office,
hardware, decor, bathroom, kids-room, outdoor,
dining-room, storage, lighting
ordering string Sort field. Prefix with - for descending:
price, -price, name, -name
search string Full-text search in name and description
min_price number Minimum price (inclusive)
max_price number Maximum price (inclusive)
has_discount string 'true' — return only products with a discount
page int Page number (default: 1)
page_size int Items per page (default: 20)
```
All parameters are optional and can be combined. The response always includes count, next, previous, and results.
Quick examples:
```python
# Cheapest 5 items in kitchen
params = {'category': 'kitchen', 'ordering': 'price', 'page_size': 5}
# All discounted products
params = {'has_discount': 'true'}
# Products matching 'table' between $50 and $300
params = {'search': 'table', 'min_price': 50, 'max_price': 300}
```
Fetch discounted products in the "dining-room" category with a price under $400, sorted alphabetically by name. Print the name and sell_price of each result.
Build a request with category="office", ordering="-price", and page_size=3. Before reading the response, print the full URL that requests constructed (including all query parameters).
import requests
BASE_URL = 'https://apilearn.tukas.dev'
params = {
'category': 'office',
'ordering': '-price',
'page_size': 3,
}
response = requests.get(f'{BASE_URL}/api/products/', params=params)
# Print the full URL that was sent
We use necessary cookies to run the site. With your permission, we can also save your site preferences and use analytics and advertising cookies to understand usage and support the project.
Open tools in tabs.Exercises, IDE tools, and trainers stay available as site tabs.
Switch without losing context.Move between explanations, code, and utilities while keeping your place.
Use the sidebar as your map.The left panels hold navigation, settings, files, libraries, and tool controls.
PythonJavaScriptSQLite
One IDE, three practical modes
Python in the browser.Run small scripts, try libraries, and practice API requests without installing anything.
JavaScript for quick experiments.Test browser-friendly code and compare ideas next to your learning materials.
SQLite for data practice.Open the database explorer to inspect tables, write queries, and learn SQL workflows locally.
TopicIDE
Work side by side with split tabs
Keep instructions visible.Open an exercise or reference page beside the IDE instead of jumping back and forth.
Compare tools while you learn.Place regex checks, explanations, and code experiments next to each other when the task needs it.
Close the split when you are done.The workspace returns to a single focused tab, and your open site tabs remain available.
Code Typing Trainer
Or plain text
This trainer is designed for a physical keyboard.Open this section on a laptop or desktop with a wide screen. Touch typing practice will not work correctly on a phone.
Speed: 0 chars/min
0 words/min
Best speed (60s): 0 chars/min
0 words/min
Errors: 0
Total time: 0.0 s
To practice touch typing, avoid looking at your physical keyboard.