Exemplo n.º 1
0
def get_structuralresources_variable_families_id_variables(
        id, limit=25, offset=0, query=None, orderby=None):
    """Get variable families (id) variables

    This function returns data from /v1.0/variablefamilies/{id}/variables

    Args:
        id (string): Variable family identificator.
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.

    Examples:
        >>> get_structuralresources_variable_families_id_variables("VRF_DEMOGRAFICAS")
    """
    # Parse query
    query = resources.parse_param(query)

    # Parse orderBy
    orderby = resources.parse_param(orderby)

    # Build URL
    api = "structural-resources"
    path = "variablefamilies"
    resource = id + "/variables" + ".json"
    params = "?limit=" + str(limit) + "&offset=" + str(
        offset) + "&query=" + query + "&orderBy=" + orderby
    resource = resource + params
    url = resources.get_url(api, path, resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 2
0
def get_structuralresources_codelists(limit=25,
                                      offset=0,
                                      query=None,
                                      orderby=None):
    """Get codelists

    This function allows to obtain the list of classifications.

    Args:
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.

    Examples:
         >>> get_structuralresources_codelists()
    """
    # Parse query
    query = resources.parse_param(query)

    # Parse orderby
    orderby = resources.parse_param(orderby)

    # Build URL
    api = "structural-resources"
    path = "codelists" + ".json"
    params = "?limit=" + str(limit) + "&offset=" + str(
        offset) + "&query=" + query + "&orderby=" + orderby
    path = path + params
    url = resources.get_url(api, path)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 3
0
def get_structuralresources_variables(limit=25,
                                      offset=0,
                                      query=None,
                                      orderby=None):
    """Get variables

    This function returns data from /v1.0/variables

    Args:
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.

    Examples:
        >>> get_structuralresources_variables()
    """
    # Parse query
    query = resources.parse_param(query)

    # Parse orderBy
    orderby = resources.parse_param(orderby)

    # Build URL
    api = "structural-resources"
    path = "variables" + ".json"
    url = resources.get_url(api, path)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 4
0
def get_indicators_systems_code_instances(indicatorsystemcode, q=None, order=None, limit=25, offset=0, fields=None,
                                          representation=None, granularity=None):
    """Get indicators system code instances

    This function returns instances of indicators associated with a specific indicator system. An instance of an
    indicator is nothing more than a spatio-temporal query of an indicator when it is incorporated into a specific
    indicator system.

    Args:
        indicatorsystemcode (string): with an indicator system code
        q (string): Query of metadata on which the searches can be built are: ``id`` and ``geographicalValue``.
        order (string): Order. Possible values are: ``update`` and ``id`` and order criteria are ``ASC`` and ``DESC``.
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        fields (string): Use of the answer by adding new fields. Possible values are: ``+metadata``, ``+data`` and
            ``+observationsMetadata``.
        representation (string): Allows filtering the observations by their value. Its use only makes sense when
            ``+data`` and/or ``+observationsMetadata`` has been included.
        granularity (string): Allows to filter the observations through the granularities of the same.
            Its use only makes sense when ``+data`` and/or ``+observationsMetadata`` has been included.

    Examples:
        >>> get_indicators_systems_code_instances("C00075H")
        >>> get_indicators_systems_code_instances("C00075H", q = 'id EQ "INDICADORES_MUNICIPALES"')
    """
    # Parse order
    order = resources.parse_param(order)

    # Parse fields
    fields = resources.parse_param(fields)

    # Parse representation
    representation = resources.parse_param(representation)

    # Parse granularity
    granularity = resources.parse_param(granularity)

    # Build URL
    api = "indicators"
    path = "indicatorsSystems"
    resource = indicatorsystemcode + "/indicatorsInstances"
    if q is not None:
        q = resources.parse_param(q)
        params = "?q=" + q + "&order=" + order + "&limit=" + str(limit) + "&offset=" + str(
            offset) + "&fields=" + fields + "&representation=" + representation + "&granularity=" + granularity
    else:
        params = "?order=" + order + "&limit=" + str(limit) + "&offset=" + str(
            offset) + "&fields=" + fields + "&representation=" + representation + "&granularity=" + granularity

    resource = resource + params
    url = resources.get_url(api, path, resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 5
0
def get_structuralresources_codelists_agency_resource_version_codes(
        agencyid,
        resourceid,
        version,
        limit=25,
        offset=0,
        query=None,
        orderby=None,
        openness=None,
        order=None,
        fields=None):
    """Get codelists agency resource version codes

    This function allows to consult the codes of a version of a classification. Note that if wildcards are used
    as ``~all`` or one of the ``limit``, ``offset``, ``query`` or ``orderBy`` parameters,
    the list will be automatically paginated.

    Args:
        agencyid (string): Agency identificator.
        resourceid (string): Resource identificator.
        version (string): Specific resource version.
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.
        openness (string): Opening established for viewing.
        order (string): Order established for visualization.
        fields (string): Additional fields that you want to show in the answer.

    Examples:
        >>> get_structuralresources_codelists_agency_resource_version_codes("ISTAC", "CL_AREA_ES", "01.000")
    """
    # Parse query
    query = resources.parse_param(query)

    # Parse orderby
    orderby = resources.parse_param(orderby)

    # Parse fields
    fields = resources.parse_param(fields)

    # Build URL
    api = "structural-resources"
    path = "codelists"
    resource = agencyid + "/" + resourceid + "/" + version + "/codes" + ".json"
    params = "?limit=" + str(limit) + "&offset=" + str(offset) + "&query=" + query + "&orderby=" + orderby + \
             "&openness=" + openness + "&order=" + order + "&fields=" + fields
    resource = resource + params
    url = resources.get_url(api, path, resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 6
0
def get_indicators(q="", order="", limit=25, offset=0, fields=None, representation=None):
    """Get indicators

    This function returns a list of indicators published in the ISTAC-indicators database. An indicator is a measure
    used to know the intensity of a phenomenon in spacetime. This measure can refer to different spatial or temporal
    granularities.

    Args:
        q (string): Metadata query on which the searches can be built using ``id``, ``subjectCode`` or
            ``geographicValue``.
        order (string): Order. Possible values are: ``update`` and ``id``. Order criteria are ``ASC`` and ``DESC``.
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        fields (string): Use of the answer by adding new fields. Possible values are: ``+metadata``, ``+data`` and
            ``+observationsMetadata``.
        representation (string): Allows filtering the observations by their value. Its use only makes sense when
            ``+data`` and/or ``+observationsMetadata`` has been included.

    Examples:
        >>> get_indicators(q = 'id IN ("AFILIACIONES", "EMPLEO_REGISTRADO_AGRICULTURA")', order = "id ASC",
                fields = "+data", representation ="GEOGRAPHICAL[35003|35005],MEASURE[ABSOLUTE]")

    """
    # URL params
    api = "indicators"
    path = "indicators"

    # Parse order
    order = resources.parse_param(order)

    # Parse fields
    fields = resources.parse_param(fields)

    # Parse representation
    representation = resources.parse_param(representation)

    # Get indicators using query (q) parameter
    if q is not None:
        q = resources.parse_param(q)
        params = "&order=" + order + "&limit=" + str(limit) + "&offset=" + str(
            offset) + "&fields=" + fields + "&representation=" + representation
        path = path + "?q=" + q + params
    else:
        params = "?order=" + order + "&limit=" + str(limit) + "&offset=" + str(
            offset) + "&fields=" + fields + "&representation=" + representation
        path = path + params

    # Get URL
    url = resources.get_url(api, path)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 7
0
def get_statisticalresources_datasets_agency_resource(agencyid,
                                                      resourceid,
                                                      lang="es",
                                                      limit=25,
                                                      offset=0,
                                                      orderby=None,
                                                      query=None):
    """Get datasets (agencyID / resourceID)
    
    This function allows to obtain all the versions of a statistical cube with a certain identifier and that also 
    maintains a certain organization.
    
    Args:
        agencyid (string): Identifier of the maintainer organization of the resource. A possible value is ``ISTAC``.
        resourceid (string): Resource identifier. A possible value is ``C00010A_000002``.
        lang (string): Language in which you want to get the answer.
        limit (int): Results limit. By default ``limit=25``.
        offset (int): Displacement. Result from which it is returned. By default ``offset=0``.
        orderby (string): Order. Possible values are ``ID ASC`` or ``ID DESC``,
        query (string): Metadata query on which the searches can be built.
        
    Examples:
        >>> get_statisticalresources_datasets_agency_resource(agencyid = "ISTAC", resourceid = "C00010A_000002")
     
    """
    # URL params
    api = "statistical-resources"
    path = "datasets"

    # Parse order
    orderby = resources.parse_param(orderby)

    # Parse query
    query = resources.parse_param(query)

    # Build URL
    params = "?lang=" + lang + "&limit=" + str(limit) + "&offset=" + str(offset) + "&orderby=" + orderby + \
             "&query=" + query
    resource = agencyid + "/" + resourceid + ".json" + params
    url = resources.get_url(api, path, resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 8
0
def get_structuralresources_geoinfo(variableid,
                                    resourceid,
                                    fields="",
                                    limit=25,
                                    offset=0,
                                    query=None,
                                    orderby=None):
    """Get geoinfo

    This function returns data from /v1.0/variables/{variableID}/variableelements/{resourceID}/geoinfo

    Args:
        variableid (string): Variable identificator.
        resourceid (string): Resource identificator.
        fields (string): Additional fields that you want to show in the answer.
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.

    Examples:
      >>> get_structuralresources_geoinfo("VR_TERRITORIO", "MUN_ICOD_VINOS")
    """
    # Parse fields
    fields = resources.parse_param(fields)

    # Parse query
    query = resources.parse_param(query)

    # Parse orderBy
    orderby = resources.parse_param(orderby)

    # Build URL
    api = "structural-resources"
    path = "variables"
    resource = variableid + "/variableelements/" + resourceid + "/geoinfo" + ".json"
    params = "?fields=" + fields + "&limit=" + str(limit) + "&offset=" + str(offset) + "&query=" + query + "&orderBy=" \
             + orderby
    resource = resource + params
    url = resources.get_url(api, path, resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 9
0
def get_structuralresources_codelists_agency_resource(agencyid,
                                                      resourceid,
                                                      limit=25,
                                                      offset=0,
                                                      query=None,
                                                      orderby=None):
    """Get codelists agency resource

    This function allows to obtain all the versions of a classification with a certain identifier and that is also kept
    by a certain organization.

    Args:
        agencyid (string): Agency identificator.
        resourceid (string): Resource identificator.
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.

    Examples:
        >>> get_structuralresources_codelists_agency_resource("ISTAC", "CL_AREA_ES")
    """
    # Parse query
    query = resources.parse_param(query)

    # Parse orderby
    orderby = resources.parse_param(orderby)

    # Build URL
    api = "structural-resources"
    path = "codelists"
    resource = agencyid + "/" + resourceid + ".json"
    params = "?limit=" + str(limit) + "&offset=" + str(
        offset) + "&query=" + query + "&orderby=" + orderby
    resource = resource + params
    url = resources.get_url(api, path, resource)

    # Get Content
    content = resources.get_content(url)

    return content
Exemplo n.º 10
0
def get_structuralresources_concept_schemes_agency_resource_version_concepts(
        agencyid,
        resourceid,
        version,
        limit=25,
        offset=0,
        query=None,
        orderby=None):
    """Get concept schemes agency resource version concepts

    This function returns the content from /v1.0/conceptschemes/{agencyID}/{resourceID}/{version}/concepts

    Args:
        agencyid (string): Identifier of the agency that publishes.
        resourceid (string): Resource identifier.
        version (string): Specific version of the resource.
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.

    Examples:
        >>> get_structuralresources_concept_schemes_agency_resource_version_concepts(agencyid = "ISTAC",
                resourceid = "CL_AREA_ES", version = "01.000")
    """
    # Parse query
    query = resources.parse_param(query)

    # Parse orderby
    orderby = resources.parse_param(orderby)

    # Build URL
    api = "structural-resources"
    path = "conceptschemes"
    resource = agencyid + "/" + resourceid + "/" + version + "/concepts"
    url = resources.get_url(api, path, resource)

    # Get content
    # content = resources.get_content(url)

    return url
Exemplo n.º 11
0
def get_indicators_systems_code_instances_code_data(indicatorsystemcode, indicatorinstancecode, representation=None,
                                                    granularity=None, fields=None):
    """Get indicators system code instances code data

    This function returns data of an indicator unit associated with a specific indicator system. An instance of an
    indicator is nothing more than a spatio-temporal query of an indicator when it is incorporated into a specific
    indicator system.

    Args:
        indicatorsystemcode (string): Indicator system code
        indicatorinstancecode (string): Indicator instance code
        representation (string): Allows filtering the observations by their value.
        granularity (string): Allows to filter the observations through the granularities of the same.
        fields (string): Allows you to customize the response by excluding fields. The possible values are:
            ``-observationsMetadata``.

    Examples:
        >>> get_indicators_systems_code_instances_code_data("C00075H", "21af0477-d63b-493b-ad02-4ab181547223")
    """
    # Parse representation
    representation = resources.parse_param(representation)

    # Parse granularity
    granularity = resources.parse_param(granularity)

    # Parse fields
    fields = resources.parse_param(fields)

    # Build URL
    api = "indicators"
    path = "indicatorsSystems"
    resource = indicatorsystemcode + "/indicatorsInstances/" + indicatorinstancecode + "/data"
    params = "?representation=" + representation + "&granularity=" + granularity + "&fields=" + fields
    resource = resource + params
    url = resources.get_url(api, path, resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 12
0
def get_statisticalresources_datasets(lang="es",
                                      limit=25,
                                      offset=0,
                                      orderby=None,
                                      query=None):
    """Get datasets

    This function allows consulting all existing statistical data cubes.

    Args:
        lang (string): Language in which you want to get the answer.
        limit (int): Results limit. By default ``limit=25``.
        offset (int): Displacement. Result from which it is returned. By default ``offset=0``.
        orderby (string): Order. Possible values are ``ID ASC`` or ``ID DESC``,
        query (string): Metadata query on which the searches can be built.

    Examples:
        >>> get_statisticalresources_datasets()
    """
    # URL params
    api = "statistical-resources"
    path = "datasets" + ".json"

    # Parse order
    orderby = resources.parse_param(orderby)

    # Parse query
    query = resources.parse_param(query)

    # Build URL
    params = "?lang=" + lang + "&limit=" + str(limit) + "&offset=" + str(offset) + "&orderby=" + orderby + \
             "&query=" + query
    path = path + params
    url = resources.get_url(api, path)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 13
0
def get_statisticalresources_datasets_agency_resource_version(
        agencyid, resourceid, version, dim=None, fields=None, lang="es"):
    """Get datasets (agencyID / resourceID / version)
    
    This function allows to obtain all the versions of a statistical cube with a certain identifier and that also 
    maintains a certain organization.
    
    Args:
        agencyid (string): Identifier of the maintainer organization of the resource. A possible value is ``ISTAC``.
        resourceid (string): Resource identifier. A possible value is ``C00010A_000002``.
        version (string): Resource version. A possible value is ``001.000``.
        dim (string): Allows filtering the data obtained in the response. A example is ``TIME_PERIOD:2009|2010``.
        fields (string): Allows you to customize the response by excluding fields from it. The possible values are
            ``-metadata`` and ``-data``.
        lang (string): Language in which you want to get the answer.
        
    Examples:
        >>> get_statisticalresources_datasets_agency_resource_version(agencyid = "ISTAC", resourceid = "C00010A_000002", 
                version = "001.000")
    """
    # URL params
    api = "statistical-resources"
    path = "datasets"

    # Parse dim
    dim = resources.parse_param(dim)

    # Parse fields
    fields = resources.parse_param(fields)

    # Build URL
    params = "?dim=" + dim + "&fields=" + fields + "&lang=" + lang
    resource = agencyid + "/" + resourceid + "/" + version + ".json" + params
    url = resources.get_url(api, path, resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 14
0
def get_structuralresources_concept_schemes_agency(agencyid,
                                                   limit=25,
                                                   offset=0,
                                                   query=None,
                                                   orderby=None):
    """Get concept schemes agency

    This function returns the content from /v1.0/conceptschemes/{agencyID}

    Args:
        agencyid (string): Identifier of the agency that publishes.
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.

    Examples:
        >>> get_structuralresources_concept_schemes_agency("ISTAC")
        >>> get_structuralresources_concept_schemes_agency("ESTAT", query = "ID EQ 2090", orderby = "ID ASC")
    """
    # Parse query
    query = resources.parse_param(query)

    # Parse orderby
    orderby = resources.parse_param(orderby)

    # Build URL
    api = "structural-resources"
    path = "conceptschemes"
    resource = agencyid
    params = "?limit=" + str(limit) + "&offset=" + str(
        offset) + "&orderby=" + orderby + "&query=" + query
    resource = resource + params
    url = resources.get_url(api, path, resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 15
0
def get_indicators_code_data(indicatorcode, representation=None, granularity="", fields=None):
    """Get indicators code data

    This function returns complete data (for all spacetime) of the indicator.
    On the other hand, metadata describing the characteristics of a specific
    indicator are offered through the metadata request, allowing the compression
    of the measured fact.

    Args:
        indicatorcode (string): an indicator code
        representation (string): Allows filtering the observations by their value.
        granularity (string): Allows to filter the observations through the granularities of the same.
        fields (string): Allows you to customize the response by excluding fields. The possible values are:
            ``-observationsMetadata``.

    Examples:
        >>> get_indicators_code_data("AFILIACIONES")
    """
    # Parse representation
    representation = resources.parse_param(representation)

    # Parse granularity
    granularity = resources.parse_param(granularity)

    # Parse fields
    fields = resources.parse_param(fields)

    # Build URL
    api = "indicators"
    path = "indicators"
    resource = indicatorcode + "/data" + "?representation=" + representation + "&granularity="\
        + granularity + "&fields=" + fields
    url = resources.get_url(api, path, resource=resource)

    # Get content
    content = resources.get_content(url)

    return content
Exemplo n.º 16
0
def get_structuralresources_concept_schemes(limit=25,
                                            offset=0,
                                            query=None,
                                            orderby=None):
    """Get concept schemes
    
    This function returns the content from /v1.0/conceptschemes
    
    Args:
        limit (int): Results limit. By default ``limit = 25``.
        offset (int): Displacement. Result from which it is returned.  By default ``offset = 0``.
        query (string): Query to filter the results.
        orderby (string): Field by which to sort the results.
        
    Examples:
        >>> get_structuralresources_concept_schemes()
        >>> get_structuralresources_concept_schemes(query = "ID EQ 2090", orderby = "ID ASC") 
    """
    # Parse query
    query = resources.parse_param(query)

    # Parse orderby
    orderby = resources.parse_param(orderby)

    # Build URL
    api = "structural-resources"
    path = "conceptschemes"
    params = "?limit=" + str(limit) + "&offset=" + str(
        offset) + "&orderby=" + orderby + "&query=" + query
    path = path + params
    url = resources.get_url(api, path)

    # Get content
    content = resources.get_content(url)

    return content