Skip to main content

Python client library for the UK Financial Services (FCA) Register RESTful API

Project description

fca-api

CI CodeQL License: MPL 2.0 PyPI version

A comprehensive async Python client library for the UK Financial Conduct Authority's Financial Services Register RESTful API.

Overview

This package provides both high-level and low-level asynchronous interfaces to interact with the FCA's Financial Services Register API. It offers type-safe, well-documented access to query information about:

  • Financial firms and their comprehensive details
  • Individual professionals in the financial services industry
  • Investment funds and collective investment schemes
  • Regulatory permissions and restrictions
  • Disciplinary actions and enforcement history
  • Regulated markets and trading venues

Note: This is an async fork of the financial-services-register-api package, completely rewritten for modern async/await patterns with comprehensive type safety and documentation.

Requirements

  • Python 3.11 or higher
  • httpx library for async HTTP requests
  • pydantic for data validation and parsing

Installation

Install from PyPI using pip:

pip install fca-api

Quick Start

Here's a simple example to get you started with the high-level client:

import asyncio
import fca_api

async def main():
    # Using async context manager (recommended)
    async with fca_api.async_api.Client(
        credentials=("your.email@example.com", "your_api_key")
    ) as client:
        
        # Search for firms by name
        firms = await client.search_frn("Barclays")
        print(f"Found {len(firms)} firms matching 'Barclays'")
        
        # Iterate through paginated results
        async for firm in firms:
            print(f"• {firm.name} (FRN: {firm.frn}) - Status: {firm.status}")
        
        # Get detailed information about a specific firm
        if len(firms) > 0:
            firm_details = await client.get_firm(firms[0].frn)
            print(f"\nFirm Details:")
            print(f"Name: {firm_details.name}")
            print(f"Status: {firm_details.status}")
            print(f"Effective Date: {firm_details.effective_date}")

if __name__ == "__main__":
    asyncio.run(main())

Architecture

The library provides two complementary interfaces:

High-Level Client (fca_api.async_api.Client)

  • Type-safe: All responses are validated with Pydantic models
  • Pagination: Automatic lazy-loading pagination with async for support
  • Convenient: Intuitive methods like search_frn(), get_firm(), etc.
  • Error handling: Meaningful exceptions and validation

Raw Client (fca_api.raw_api.RawClient)

  • Direct access: Minimal abstraction over HTTP API
  • Flexible: For advanced use cases and custom processing
  • Performance: Lower overhead for bulk operations
  • Testing: Ideal for debugging and API exploration

Key Features

  • Asynchronous Operations: Built with async/await for efficient concurrent requests
  • Comprehensive Documentation: Extensive docstrings and examples for all methods
  • Type Safety: Full type annotation support with Pydantic validation
  • Smart Pagination: Lazy-loading pagination with automatic page fetching
  • Robust Error Handling: Meaningful exceptions with detailed context
  • High Performance: Optimized for both single queries and bulk operations
  • Well Tested: Comprehensive test suite with response caching
  • Extensible: Clean architecture for custom extensions

Usage Examples

Searching and Pagination

import fca_api

async with fca_api.async_api.Client(credentials=("email", "key")) as client:
    # Search returns a lazy-loading paginated list
    results = await client.search_frn("revolution")
    
    # Check total results without loading all pages
    print(f"Total results: {len(results)}")
    
    # Access specific items by index (loads pages as needed)
    first_result = results[0]
    
    # Iterate through all results efficiently
    async for firm in results:
        print(f"{firm.name} - {firm.status}")
    
    # Or load all pages at once for bulk processing
    await results.fetch_all_pages()

Firm Information

# Get comprehensive firm details
firm = await client.get_firm("123456")  # Using FRN
print(f"Firm: {firm.name}")
print(f"Status: {firm.status}")

# Get related information
addresses = await client.get_firm_addresses("123456")
permissions = await client.get_firm_permissions("123456")
individuals = await client.get_firm_individuals("123456")

async for address in addresses:
    print(f"Address: {', '.join(address.address_lines)}")

Individual and Fund Searches

# Search for individuals
individuals = await client.search_irn("John Smith")
async for person in individuals:
    print(f"{person.name} (IRN: {person.irn})")

# Search for funds/products
funds = await client.search_prn("Vanguard")
async for fund in funds:
    print(f"{fund.name} (PRN: {fund.prn})")

Error Handling

import fca_api.exc

try:
    firm = await client.get_firm("invalid_frn")
except fca_api.exc.FcaRequestError as e:
    print(f"API request failed: {e}")
except fca_api.exc.FcaBaseError as e:
    print(f"General API error: {e}")

Rate Limiting

from asyncio_throttle import Throttler

# Limit to 10 requests per second
throttler = Throttler(rate_limit=10)

async with fca_api.async_api.Client(
    credentials=("email", "key"),
    api_limiter=throttler
) as client:
    # All requests will be automatically rate limited
    results = await client.search_frn("test")

Raw Client Usage

For advanced use cases or when you need direct API access:

import fca_api.raw

client = fca_api.raw_api.RawClient(
    credentials=("email", "key")
)

# Direct API calls return raw responses
response = await client.search_frn("Barclays", page=0)

if response.fca_api_status == "Success":
    for item in response.data:
        print(f"Raw data: {item}")
        
print(f"Pagination info: {response.result_info}")

Documentation

The library includes comprehensive documentation:

  • In-code documentation: All classes and methods have detailed docstrings
  • Type hints: Complete type information for IDE support
  • Examples: Practical examples in every docstring
  • API reference: Auto-generated from docstrings (Sphinx-compatible)

Access documentation in your IDE or Python REPL:

import fca_api
help(fca_api.async_api.Client)           # High-level client
help(fca_api.async_api.Client.search_frn) # Specific method
help(fca_api.types.firm.FirmDetails) # Response types

For complete API reference and advanced usage, visit the full documentation.

Contributing

Contributions are welcome! Please see contributing guidelines on how to contribute to this project.

License

This project is licensed under the Mozilla Public License 2.0. See the LICENSE file for details.

Support

If you encounter any issues or have questions, please:

  1. Check the comprehensive in-code documentation with help()
  2. Review the complete documentation
  3. Search existing GitHub issues
  4. Create a new issue if your problem hasn't been addressed

API Authentication

To use this library, you need API credentials from the FCA Developer Portal:

  1. Visit FCA Developer Portal
  2. Register for an account
  3. Generate API credentials (email and API key)
  4. Use these credentials when initializing the client

Note: Keep your API credentials secure and never commit them to version control.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fca_api-1.1.0.tar.gz (46.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fca_api-1.1.0-py3-none-any.whl (50.2 kB view details)

Uploaded Python 3

File details

Details for the file fca_api-1.1.0.tar.gz.

File metadata

  • Download URL: fca_api-1.1.0.tar.gz
  • Upload date:
  • Size: 46.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.6 CPython/3.13.12 Linux/6.14.0-1017-azure

File hashes

Hashes for fca_api-1.1.0.tar.gz
Algorithm Hash digest
SHA256 72c8284f9c5edd91e66534cd33ea1c2120eba959c38021846433ad82f15a54d5
MD5 4e50cb63ef10201361d8e6b5591bb467
BLAKE2b-256 3b9c705abb4cc237caa6b4eca6f7202e2113b6c5b008fe6ead1d7a6965e39551

See more details on using hashes here.

File details

Details for the file fca_api-1.1.0-py3-none-any.whl.

File metadata

  • Download URL: fca_api-1.1.0-py3-none-any.whl
  • Upload date:
  • Size: 50.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: pdm/2.26.6 CPython/3.13.12 Linux/6.14.0-1017-azure

File hashes

Hashes for fca_api-1.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 fa69342b3cdad366b6cd24edc8f8ad05d04470e4d6d26ab1d8875c53b9be4596
MD5 6923aaa3967488330723573df86d4741
BLAKE2b-256 a355c080a72c7790462759b5cdba3e43c9aa9d7cfae96a3a7a57271546493d61

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page