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
SQL sql
SQL (3NF) sql_3nf
SQLite sqlite
SQLite (3NF) sqlite_3nf
Turtle ttl
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",
        "CrossSectionArea",
        "NetVolume"
    ]
}

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

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.1.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.1-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ifc2data-1.2.1.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.1.tar.gz
Algorithm Hash digest
SHA256 b8a1df1e4624937f16ea414e02774d8bf6ed060d43db9390dbd5595a01d61a27
MD5 6365477dfae1fa8cece1afb29409f995
BLAKE2b-256 0c273537d8598986f2a4bc51c99216991ddaf5df1f0520369abb2d4e7925def2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ifc2data-1.2.1-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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 87b82f9c6cb8c4a84afac09f83b82dc0372e590a519740541d6ab954b561b158
MD5 28f2fae66c586f5bee7605ea90488604
BLAKE2b-256 dc98af2fae64da277132c261be5b978fbaabdc1aa2cf4b2b2a8934c266fcb711

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