Skip to main content

Python client for the Ifc2Data API

Project description

Ifc2Data Python Client

A Python client for the Ifc2Data API https://www.ifc2data.com/

Ifc2Data allows you to upload IFC files and export structured datasets in multiple formats such as XLSX, CSV, SQL, JSON, and more.

This package provides both:

  • A synchronous client (Client)
  • An asynchronous client (AsyncClient)

for seamless integration into Python applications, automation workflows, and backend services.


Features

  • Synchronous and asynchronous support
  • Multiple output formats supported
  • Built-in parameter validation
  • Automatic retry mechanism for network reliability
  • Lightweight and easy to integrate

Installation

pip install ifc2data

Prerequisites

Before using this package :

  1. Create an account on Ifc2Data : https://www.ifc2data.com/signup/
  2. Request an API key : yohann.schatz@hesge.ch

Quick Start

Synchronous Client

from ifc2data import Client

api_key = "YOUR_API_KEY"

file_path = r"C:\path\to\your\file\File.ifc"

output_format = "xlsx"

parameters = {
    "elements": ["IfcWall"],
    "properties": ["IsExternal", "LoadBearing"],
    "quantities": []
}

client = Client(api_key)

result = client.run(
    file_path=file_path,
    output_format=output_format,
    parameters=parameters
)

if result.done:
    output_path = client.download(
        result,
        r"C:\path\to\your\file"
    )

    print("Saved to:", output_path)

Asynchronous Client

import asyncio
from ifc2data import AsyncClient

api_key = "YOUR_API_KEY"

file_path = r"C:\path\to\your\file\File.ifc"

output_format = "xlsx"

parameters = {
    "elements": ["IfcWall"],
    "properties": ["IsExternal", "LoadBearing"],
    "quantities": []
}

async def main():

    client = AsyncClient(api_key)

    result = await client.run(
        file_path=file_path,
        output_format=output_format,
        parameters=parameters
    )

    if result.done:

        output_path = await client.download(
            result,
            r"C:\path\to\your\file"
        )

        print("Saved to:", output_path)

asyncio.run(main())

How it works

  1. Upload an IFC model
  2. Configure extraction parameters
  3. Execute the processing pipeline
  4. Receive a structured API response
  5. Download the generated output file

Response

Response Object

The run() method returns a PipelineResponse object.

print(result.status)
print(result.message)

if result.data:
    print(result.data.id)
    print(result.data.file_name)

Response Structure

Attribute Type Description
status str Pipeline execution status
message str Human-readable API message
data PipelineData Processed file information
done bool Returns True if processing succeeded

Output Formats

Format Key
BSON (MongoDB) bson
CSV csv
JSON json
RDF rdf
SQL sql
SQL (3NF) sql_3nf
SQLite sqlite
SQLite (3NF) sqlite_3nf
Excel (XLSX) xlsx

Parameters

The parameters dictionary controls how IFC data is filtered and exported.

Available Parameters

Key Required Type Empty Allowed Description
elements Yes List[str] No IFC classes to extract
classifications No List[str] Yes Classification filters
documents No List[str] Yes Document filters
materials No List[str] Yes Material filters
properties No List[str] Yes Property filters
quantities No List[str] Yes Quantity filters

Parameter Examples

Minimal Example

parameters = {
    "elements": ["IfcWall"]
}

Multiple IFC Elements

parameters = {
    "elements": [
        "IfcWall",
        "IfcDoor",
        "IfcWindow"
    ]
}

Property Filtering

parameters = {
    "elements": ["IfcWall"],
    "properties": [
        "FireRating",
        "LoadBearing",
        "IsExternal"
    ]
}

Material Filtering

parameters = {
    "elements": ["IfcSlab"],
    "materials": [
        "Concrete",
        "Steel"
    ]
}

Quantity Extraction

parameters = {
    "elements": ["IfcBeam"],
    "quantities": [
        "Length",
        "Area",
        "Volume"
    ]
}

No Filter Example

parameters = {
    "elements": ["IfcWall"],
    "properties": []
}

Validation Rules

The SDK validates parameters before sending requests to the API.

Validation includes:

  • Required parameter checks
  • Output format validation
  • IFC class validation
  • Parameter type validation
  • Unknown parameter detection

Invalid configurations raise a ValueError.


Error Handling

try:

    result = client.run(
        file_path,
        output_format,
        parameters
    )

except ValueError as e:
    print("Validation error:", e)

except Exception as e:
    print("Request failed:", e)

Verbose Mode

Enable verbose mode to inspect API requests and responses.

result = client.run(
    file_path=file_path,
    output_format="xlsx",
    parameters=parameters,
    verbose=True
)

Verbose mode displays:

  • Request URL
  • Output format
  • Parameters
  • HTTP response status
  • API response payload

Notes

  • IFC files must be valid and readable
  • Network retries are automatically handled internally
  • Empty filter lists are normalized automatically
  • Downloaded files are streamed to disk to reduce memory usage

License

This project is licensed under the MIT License.


Author

Yohann Schatz

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

ifc2data-1.2.0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

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

ifc2data-1.2.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file ifc2data-1.2.0.tar.gz.

File metadata

  • Download URL: ifc2data-1.2.0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ifc2data-1.2.0.tar.gz
Algorithm Hash digest
SHA256 d790c6e04a5f1b3168775b7d77612ae2ec099f7d9a53e6027cb07b7683ff23f9
MD5 4e883a13d7cb8c962ba4f423cf437d68
BLAKE2b-256 0a297bc0146123aa76999686aec186106863660fd0f734e3bc6f95af1ee17e00

See more details on using hashes here.

File details

Details for the file ifc2data-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: ifc2data-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for ifc2data-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 4cc2017437dc15e0ca7cb82f88c62bd71c05b7a37f70ed7bc0acfb6d107b12a2
MD5 b6a64179314d9228951fa3ee1802293d
BLAKE2b-256 8b5deed4edf912ee75c20c46fd5a40a49ed86455acbf8a75a92b9f2792d095bf

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