Skip to content

Sites

Exposes FIO Sites data for users, either as whole site data or warehouses. All Sites data requires a FIO API KEY. You will need to have access to the data the user has in FIO in order to access it.

Example

from fio_wrapper import FIO

fio = FIO(api_key="your_api_key")

# Get users warehouses
user_warehouses = fio.Sites.warehouses(username="PrUn username")

# Get users complete sites data incl. buildings, 
# their condition and repair / reclaimable materials
user_sites = fio.Sites.get(username="PrUn username")

# Get users sites data for specific planet incl. buildings, 
# their condition and repair / reclaimable materials
user_sites = fio.Sites.get_planet(username="PrUn username", planet="Montem")

Endpoints

Access site information from FIO.

Sites

Bases: AbstractSites, AbstractEndpoint

get

get(username, timeout=None)

Gets site data for given username from FIO

Note

FIO API Key Required

Parameters:

Name Type Description Default
username str

Prosperous Universe username

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
NoSiteData

Username has no site data

NotAuthenticated

Not authenticated or no appropiate permissions

Returns:

Type Description
SiteList

Site | SiteList: Site or List of Sites

Source code in fio_wrapper/endpoints/endpoints_v1/sites.py
@apikey_required
def get(self, username: str, timeout: Optional[float] = None) -> SiteList:
    """Gets site data for given username from FIO

    Note:
        FIO API Key Required

    Args:
        username (str): Prosperous Universe username
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        NoSiteData: Username has no site data
        NotAuthenticated: Not authenticated or no appropiate permissions

    Returns:
        Site | SiteList: Site or List of Sites
    """

    (status, data) = self.adapter.get(
        endpoint=self.urls.sites_get_url(username=username),
        err_codes=[204, 401],
        timeout=timeout,
    )

    if status == 200:
        return SiteList.model_validate(data)

    elif status == 204:
        raise NoSiteData("Username has no site data")
    elif status == 401:
        raise NotAuthenticated("Not authenticated or no appropiate permissions")

get_planet

get_planet(username, planet, timeout=None)

Gets site data for given username and planet from FIO

Note

FIO API Key Required

Parameters:

Name Type Description Default
username str

Prosperous Universe username

required
planet str

PlanetId, PlanetNaturalId or PlanetName. Defaults to None.

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
NoSiteData

Username has no site data

NotAuthenticated

Not authenticated or no appropiate permissions

Returns:

Name Type Description
Site Site

Site

Source code in fio_wrapper/endpoints/endpoints_v1/sites.py
@apikey_required
def get_planet(
    self, username: str, planet: str, timeout: Optional[float] = None
) -> Site:
    """Gets site data for given username and planet from FIO

    Note:
        FIO API Key Required

    Args:
        username (str): Prosperous Universe username
        planet (str): PlanetId, PlanetNaturalId or PlanetName. Defaults to None.
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        NoSiteData: Username has no site data
        NotAuthenticated: Not authenticated or no appropiate permissions

    Returns:
        Site: Site
    """

    (status, data) = self.adapter.get(
        endpoint=self.urls.sites_planets_get_planet_url(
            username=username, planet=planet
        ),
        err_codes=[204, 401],
        timeout=timeout,
    )

    if status == 200:
        return Site.model_validate(data)
    elif status == 204:
        raise NoSiteData("Username has no site data")
    elif status == 401:
        raise NotAuthenticated("Not authenticated or no appropiate permissions")

planets

planets(username, timeout=None)

Gets a list of SiteIds from FIO for given username

Note

FIO API Key Required

Parameters:

Name Type Description Default
username str

Prosperous Universe username

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
NoSiteData

Username has no site data

NotAuthenticated

Not authenticated or no appropiate permissions

Returns:

Type Description
List[str]

List[str]: List of SiteIds

Source code in fio_wrapper/endpoints/endpoints_v1/sites.py
@apikey_required
def planets(self, username: str, timeout: Optional[float] = None) -> List[str]:
    """Gets a list of SiteIds from FIO for given username

    Note:
        FIO API Key Required

    Args:
        username (str): Prosperous Universe username
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        NoSiteData: Username has no site data
        NotAuthenticated: Not authenticated or no appropiate permissions

    Returns:
        List[str]: List of SiteIds
    """
    (status, data) = self.adapter.get(
        endpoint=self.urls.sites_planets_get_url(username=username),
        err_codes=[204, 401],
        timeout=timeout,
    )

    if status == 200:
        return data
    elif status == 204:
        raise NoSiteData("Username has no site data")
    elif status == 401:
        raise NotAuthenticated("Not authenticated or no appropiate permissions")

warehouses

warehouses(username, timeout=None)

Get warehouse data for username from FIO

Note

FIO API Key Required

Parameters:

Name Type Description Default
username str

Prosperous Universe username

required
timeout float

Request timeout in seconds. Defaults to None.

None

Raises:

Type Description
NoSiteData

Username has no warehouse site data

NotAuthenticated

Not authenticated or no appropiate permissions

Returns:

Name Type Description
WarehouseList WarehouseList

List of Warehouses

Source code in fio_wrapper/endpoints/endpoints_v1/sites.py
@apikey_required
def warehouses(
    self, username: str, timeout: Optional[float] = None
) -> WarehouseList:
    """Get warehouse data for username from FIO

    Note:
        FIO API Key Required

    Args:
        username (str): Prosperous Universe username
        timeout (float, optional): Request timeout in seconds. Defaults to None.

    Raises:
        NoSiteData: Username has no warehouse site data
        NotAuthenticated: Not authenticated or no appropiate permissions

    Returns:
        WarehouseList: List of Warehouses
    """
    (status, data) = self.adapter.get(
        endpoint=self.urls.sites_warehouses_get(username=username),
        err_codes=[204, 401],
        timeout=timeout,
    )

    if status == 200:
        return WarehouseList.model_validate(data)
    elif status == 204:
        raise NoSiteData("Username has no warehouse site data")
    elif status == 401:
        raise NotAuthenticated("Not authenticated or no appropiate permissions")