Hacktoberfest 2026: the issues maintainers tagged for October, open and beginner-friendly. Browse Hacktoberfest issues

Add Device Detection Support

Open
#51 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
45/100
Issue type
Feature
Clarity
Mostly clear
Activity status
Stale
Tech stack
python
Domain
api

Research direction

Start with the WIT bindings in stubs/wit_world/imports/device_detection.py and inspect Viceroy's device-detection implementation to determine available test responses. Add the function-based lookup API and DeviceInfo dataclass with forward-compatible unknown fields, then test parsing, error handling, and unmatched lookups using synthetic responses or appropriate xfail cases.

Written by the indexing model from the issue text.

Description

Overview

Add support for Fastly's Device Detection API, which provides device capabilities and characteristics based on User-Agent strings.

WIT Interface

interface device-detection {
  use types.{error};

  /// Returns JSON-encoded device data for a User-Agent string
  lookup: func(user-agent: string, max-len: u64) -> result<option<string>, error>;
}

WIT bindings: stubs/wit_world/imports/device_detection.py

API Design

  • Simple function-based API: lookup(user_agent: str) -> Optional[DeviceInfo]
  • Parse JSON response into @dataclass with _extra field for forward compatibility
  • Return None for lookups that don't match any known device
  • Fields typically include: is_mobile, is_desktop, is_tablet, is_bot, device_type, brand, model, etc.

Forward Compatibility: Use @dataclass with _extra: dict field to capture unknown fields (same pattern as Geo). Provides type hints for known fields while allowing future fields to be accessible.

Cross-SDK Comparison: All SDKs expose simple lookup(user_agent) returning parsed JSON. Rust returns DeviceInfo struct, Go returns *DeviceDetection, JS returns object. All have similar field structure (device type, name, vendor, etc.).

Viceroy Testing

Device detection support in Viceroy is limited or stubbed. The WIT interface exists but may not have full test data support via test.toml configuration like other features.

Tests should either:

  • Use xfail markers for functionality that requires production device detection data
  • Mock the User-Agent lookup if Viceroy provides stub/default responses
  • Focus on API wrapper behavior (parsing, error handling) with synthetic responses

Check Viceroy's device detection implementation to determine exact testing capabilities.

Reference

Dominant language
Python
Stars
5
Forks
1
PR merge metrics
No merged PRs in 30d

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from fastly/compute-sdk-python

All issues in fastly/compute-sdk-python

Similar issues

More Python issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.