Overview
FKAPI provides bulk endpoints optimized for fetching multiple kits in a single request. FootyCollect uses these endpoints to efficiently import user collections from the Football Kit Archive.Bulk Fetch Kits
Method
Fetch multiple kits by their slugs in a single API call:Implementation
Source:client.py:486-515
Constraints
int
default:"2"
Minimum number of slugs required for bulk endpointRequests with fewer than 2 slugs will return an empty list
int
default:"30"
Maximum number of slugs supported per requestRequests with more than 30 slugs will be automatically truncated
client.py:14-16:
Response Format
Bulk responses use a reduced format for efficiency:Bulk responses exclude some fields present in detailed kit responses to reduce payload size. Use
get_kit_details() if you need complete kit information.User Collection Import
Management Command
FootyCollect includes a Django management command for importing entire user collections from the Football Kit Archive:footycollect/collection/management/commands/populate_user_collection.py
Command Arguments
int
required
User ID from FootballKitArchiveExample:
12345string
Username in your FootyCollect instance to assign items toDefault: Creates new user based on FKA profile
int
default:"120"
Maximum time to wait for scraping to complete (seconds)Default: 120 seconds
int
default:"20"
Number of items to fetch per pageDefault: 20
boolean
default:"false"
Dry run mode - preview what would be created without actually creating objectsUseful for testing imports
string
Path to JSON file with collection data (for testing/offline imports)Bypasses FKAPI calls
Usage Examples
How It Works
Thepopulate_user_collection command performs the following steps:
1. Initiate Scraping
Calls FKAPI to start scraping the user’s collection:
Brand,Club,Season,TypeK,Competition,Kit(if they don’t exist)BaseItemwith metadataJerseywith size and customization detailsPhotoobjects from entry images
The command uses transactions to ensure atomicity - if an entry fails to import, it won’t leave partial data in the database.
FKAPI Client Methods
Scrape User Collection
client.py:532-537
Get User Collection
client.py:539-546
int
default:"1"
Page number (1-indexed)
int
default:"20"
Number of entries per page
boolean
default:"false"
Whether to use cached resultsTypically disabled for user collection imports to ensure fresh data
Batch Processing Best Practices
Split Large Imports
For collections with hundreds of kits, split into batches:Handle Failures Gracefully
Thepopulate_user_collection command tracks success/failure:
Avoid Duplicates
The command checks for existing items before creating:populate_user_collection.py:722-736
Existing items are skipped to prevent duplicates. Re-running the command on the same user is safe.
Rate Limiting for Bulk Operations
Bulk operations are subject to the same rate limits as regular requests:- Client-side: 100 requests per minute
- Each bulk request counts as 1 request, regardless of how many slugs it contains
Optimize Request Count
Error Handling
Empty Results
Partial Failures
If some slugs are invalid, FKAPI returns only valid kits:Command Errors
The management command provides detailed error output:Advanced Usage
Custom Pagination
Adjust page size for performance tuning:Offline Import from JSON
For testing or offline scenarios:Selective Import
Modify the command to filter entries:Performance Considerations
Database Transactions
Each entry is processed in a transaction for safety:Asset Downloads
Logos and photos are downloaded asynchronously to avoid blocking:Constraints Summary
Next Steps
- Review FKAPI overview for architecture and configuration
- Learn about searching kits for individual kit queries
- Explore the API reference for endpoint details