Skip to content

Commit 7e99850

Browse files
committed
field selection
1 parent d195491 commit 7e99850

15 files changed

+809
-348
lines changed

README.md

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,3 +385,127 @@ Or in case of an error:
385385
]
386386
}
387387
```
388+
389+
## Field Selection API Documentation
390+
391+
### Overview
392+
393+
The categories and technologies endpoints now support custom field selection, allowing clients to specify exactly which fields they want in the response. This feature helps reduce payload size and improves API performance by returning only the needed data.
394+
395+
### Endpoints Supporting Field Selection
396+
397+
- `GET /v1/technologies`
398+
- `GET /v1/categories`
399+
400+
### Usage
401+
402+
#### Basic Syntax
403+
404+
Add a `fields` parameter to your request with comma-separated field names:
405+
406+
```
407+
GET /v1/technologies?fields=technology,category
408+
GET /v1/categories?fields=category,description
409+
```
410+
411+
#### Examples
412+
413+
##### Technologies Endpoint
414+
415+
**Get only technology names and categories:**
416+
417+
```
418+
GET /v1/technologies?fields=technology,category
419+
```
420+
421+
Response:
422+
423+
```json
424+
{
425+
"data": [
426+
{
427+
"technology": "React",
428+
"category": "JavaScript Frameworks"
429+
},
430+
{
431+
"technology": "Angular",
432+
"category": "JavaScript Frameworks"
433+
}
434+
]
435+
}
436+
```
437+
438+
**Get technology names and descriptions:**
439+
440+
```
441+
GET /v1/technologies?fields=technology,description
442+
```
443+
444+
**Combine with existing filters:**
445+
446+
```
447+
GET /v1/technologies?category=JavaScript%20Frameworks&fields=technology,icon
448+
```
449+
450+
##### Categories Endpoint
451+
452+
**Get only category names:**
453+
454+
```
455+
GET /v1/categories?fields=category
456+
```
457+
458+
**Get categories with descriptions:**
459+
460+
```
461+
GET /v1/categories?fields=category,description
462+
```
463+
464+
#### Behavior Notes
465+
466+
1. **Field Priority**: The `fields` parameter takes precedence over other response formatting options, except for `onlyname`
467+
2. **Invalid Fields**: Non-existent fields are silently ignored
468+
3. **Empty Fields**: If no valid fields are specified, the full object is returned
469+
4. **Backward Compatibility**: When `fields` is not specified, endpoints return their default response format
470+
5. **onlyname Override**: The `onlyname` parameter still takes precedence over `fields` for backward compatibility
471+
472+
#### Available Fields
473+
474+
##### Technologies Endpoint
475+
476+
- `technology` - Technology name
477+
- `category` - Category name
478+
- `description` - Technology description
479+
- `icon` - Icon filename
480+
- `origins` - Array of origin companies/organizations
481+
482+
##### Categories Endpoint
483+
484+
- `category` - Category name
485+
- Additional fields depend on your data structure
486+
487+
#### Error Handling
488+
489+
The field selection feature handles errors gracefully:
490+
491+
- Invalid field names are ignored
492+
- Empty field lists return full objects
493+
- Malformed field parameters fallback to default behavior
494+
495+
#### Performance Benefits
496+
497+
- **Reduced Payload Size**: Only requested fields are included
498+
- **Faster Parsing**: Clients process smaller JSON objects
499+
- **Bandwidth Savings**: Less data transferred over the network
500+
- **Improved Caching**: More specific responses can be cached more effectively
501+
502+
#### Migration Guide
503+
504+
Existing API consumers are not affected by this change. The field selection feature is entirely opt-in through the `fields` parameter.
505+
506+
To adopt field selection:
507+
508+
1. Identify which fields your application actually uses
509+
2. Add the `fields` parameter with those field names
510+
3. Update your client code to handle the new response structure
511+
4. Test thoroughly with your specific use cases

0 commit comments

Comments
 (0)