Skip to main content

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
Defined in client.py:14-16:
The bulk endpoint will truncate slug lists exceeding 30 items. For larger imports, split your requests into multiple batches of 30 slugs or fewer.

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:
Source: footycollect/collection/management/commands/populate_user_collection.py

Command Arguments

int
required
User ID from FootballKitArchiveExample: 12345
string
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

The populate_user_collection command performs the following steps: 1. Initiate Scraping Calls FKAPI to start scraping the user’s collection:
2. Wait for Completion Polls FKAPI until collection data is ready:
3. Fetch All Pages Iterates through paginated results:
4. Create Objects For each entry, creates:
  • Brand, Club, Season, TypeK, Competition, Kit (if they don’t exist)
  • BaseItem with metadata
  • Jersey with size and customization details
  • Photo objects from entry images
5. Download Assets Downloads club logos, brand logos, and kit photos automatically.
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

Source: client.py:532-537

Get User Collection

Source: 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

The populate_user_collection command tracks success/failure:

Avoid Duplicates

The command checks for existing items before creating:
Source: 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:
Large imports with many photos can take significant time. Use --dry-run first to estimate duration.

Constraints Summary

Next Steps