Optimizing API Responses with Field Selection
Reduce payload sizes and speed up your app by requesting only the columns you need.
Why field selection matters
When your CSV has many columns but your app only needs a few, you're transferring unnecessary data on every request. The fields parameter lets you specify exactly which columns to return, reducing payload size and improving response times.
This is especially impactful for datasets with wide rows (many columns) or large text fields.
Basic usage
Pass a comma-separated list of column names to the fields parameter:
Return only name and price:
curl -H "Authorization: Bearer YOUR_API_KEY" \ "https://csv-api.com/api/v1/datasets/YOUR_ID/records?fields=name,price"
Response:
{
"data": [
{ "name": "Wireless Mouse", "price": 29.99 },
{ "name": "Standing Desk", "price": 449.00 }
],
"meta": { "total": 5, "page": 1, "per_page": 25, "total_pages": 1 }
}
Real-world example: a product dropdown
Imagine you're building a product selection dropdown. You only need the ID and name — not the description, price, category, images, or any other columns:
# Without field selection — returns ALL columns ?per_page=100 # With field selection — returns only what you need ?fields=name&per_page=100
If your dataset has 20 columns, this could reduce response size by 90% or more.
Combining with filters and sorting
Field selection works alongside all other query parameters. You can filter, sort, paginate, and select fields in a single request:
# Get names and prices of in-stock electronics, sorted by price ?fields=name,price&\ filter[category]=Electronics&\ filter[in_stock]=true&\ sort=price&\ per_page=50
Performance tips
Beyond field selection, here are more ways to optimize your csv-api usage:
-
1
Use appropriate page sizes. Larger pages mean fewer requests but bigger payloads. For tables, 25-50 records per page is usually optimal. For dropdowns or autocompletes, 100 with field selection works well.
-
2
Cache responses client-side. If your data doesn't change frequently, cache API responses in memory or localStorage to avoid redundant requests.
-
3
Debounce search inputs. When building a search-as-you-type feature, wait 200-300ms after the user stops typing before making an API call (as shown in the frontend tutorial).
-
4
Be mindful of rate limits. The Free plan allows 100 requests/hour, Pro allows 1,000, and Enterprise 10,000. Design your app to stay within your plan's limits.
Monitoring your usage
Visit the Usage page in your csv-api dashboard to see API request counts broken down by dataset and time period (daily, weekly, monthly). This helps you understand your traffic patterns and decide if you need to upgrade your plan or optimize your request patterns.
We use essential cookies to keep you logged in. No tracking or analytics. Privacy policy