def get_structuralresources_geoinfo( variableid, resourceid, fields='', limit=25, offset=0, query='', orderby='' ): """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") """ path = '/'.join(['variables', variableid, 'variableelements', resourceid, 'geoinfo']) url = services.build_entrypoint_url( API, path, fields=fields, limit=limit, offset=offset, query=query, orderBy=orderby ) return services.get_content(url)
def get_structuralresources_concept_schemes_agency_resource_version_concepts_id( agencyid, resourceid, version, conceptid): """Get concept schemes agency resource version concepts (id) This function returns the content from ``/v1.0/conceptschemes/{agencyID}/{resourceID}/{version}/concepts/{conceptID}`` Args: agencyid (string): Identifier of the agency that publishes. resourceid (string): Resource identifier. version (string): Specific version of the resource. conceptid (string): Concept identifier. Examples: >>> get_structuralresources_concept_schemes_agency_resource_version_concepts_id( ... agencyid="ISTAC", ... resourceid="CSM_C00010A_SIE", ... version="01.000", ... conceptID="ELECTORES" ... ) """ path = '/'.join([ 'conceptschemes', agencyid, resourceid, version, 'concepts', conceptid ]) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_structuralresources_codelist_families(limit=25, offset=0, orderby='', query=''): """Get codelist families This function returns the list of families of classifications Args: limit (int): Results limit. By default ``limit = 25``. offset (int): Displacement. Result from which it is returned. By default ``offset = 0``. orderby (string): Field by which to sort the results. query (string): Query to filter the results. Examples: >>> get_structuralresources_codelist_families() """ path = 'codelistfamilies' url = services.build_entrypoint_url(API, path, limit=limit, offset=offset, orderBy=orderby, query=query) return services.get_content(url)
def get_indicators_code_data(indicatorcode, representation='', granularity='', fields=''): """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") """ path = '/'.join(['indicators', indicatorcode, 'data']) url = services.build_entrypoint_url(API, path, representation=representation, granularity=granularity, fields=fields) return services.get_content(url)
def get_statisticalresources_queries(lang='es', limit=25, offset=0, orderby='', query=''): """Get queries This function allows consulting all existing statistical queries. 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_queries() """ path = 'queries' url = services.build_entrypoint_url(API, path, lang=lang, limit=limit, offset=offset, orderBy=orderby, query=query) return services.get_content(url)
def get_statisticalresources_queries_agency(agencyid, lang='es', limit=25, offset=0, orderby='', query=''): """Get queries (agencyID) This function allows to consult all the queries maintained by a certain organization. Args: agencyid (string): Identifier of the maintainer organization of the resource. A possible value is ``ISTAC``. 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_queries_agency(agencyid="ISTAC") """ path = '/'.join(['queries', agencyid]) url = services.build_entrypoint_url(API, path, lang=lang, limit=limit, offset=offset, orderBy=orderby, query=query) return services.get_content(url)
def get_indicators_systems_code_instances_code(indicatorsystemcode, indicatorinstancecode): """Get indicators system code instances code This function returns metadata of an indicator set 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 Examples: >>> get_indicators_systems_code_instances_code( ... "C00075H", ... "21af0477-d63b-493b-ad02-4ab181547223" ... ) """ path = '/'.join([ 'indicatorsSystems', indicatorsystemcode, 'indicatorsInstances', indicatorinstancecode, ]) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_indicators_geographical_values(geographicalgranularitycode, subjectcode='', systemcode=''): """Get geographical values This function returns values of a geographical granularity that in turn are part of a specific theme or system of indicators. Args: geographicalgranularitycode (string): geographical granularity code subjectcode (string): subject code systemcode (string): system code Examples: >>> get_indicators_geographical_values("REGIONS") >>> get_indicators_geographical_values( ... "REGIONS", ... subjectcode="051", ... systemcode="C00067A" ) """ path = 'geographicalValues' url = services.build_entrypoint_url( API, path, geographicalGranularityCode=geographicalgranularitycode, subjectCode=subjectcode, systemCode=systemcode, ) return services.get_content(url)
def get_structuralresources_concept_schemes(limit=25, offset=0, query='', orderby=''): """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" ... ) """ path = 'conceptschemes' url = services.build_entrypoint_url(API, path, limit=limit, offset=offset, query=query, orderBy=orderby) return services.get_content(url)
def get_structuralresources_concept_schemes_agency_resource( agencyid, resourceid, limit=25, offset=0, query='', orderby=''): """Get concept schemes agency resource This function returns the content from ``/v1.0/conceptschemes/{agencyID}/{resourceID}`` Args: agencyid (string): Identifier of the agency that publishes. resourceid (string): Resource identifier. 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( ... agencyid="ISTAC", ... resourceid="CSM_C00010A_SIE" ... ) """ path = '/'.join(['conceptschemes', agencyid, resourceid]) url = services.build_entrypoint_url(API, path, limit=limit, offset=offset, query=query, orderBy=orderby) return services.get_content(url)
def get_structuralresources_codelists_agency(agencyid, limit=25, offset=0, query='', orderby=''): """Get codelists agency This function allows obtaining the list of all the classifications maintained by a certain organization. Args: agencyid (string): Agency 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("ISTAC") >>> get_structuralresources_codelists_agency("ESTAT") """ path = '/'.join(['codelists', agencyid]) url = services.build_entrypoint_url(API, path, limit=limit, offset=offset, query=query, orderBy=orderby) return services.get_content(url)
def get_structuralresources_content_constraints_agency_resource_version_regions( regioncode, agencyid, resourceid, version ): """Get content constraints agency resource version regions This function returns the content from ``/v1.0/contentConstraints/{agencyID}/{resourceID}/{version}/regions/`` {regionCode} Args: regioncode (string) Region code. agencyid (string) Identifier of the agency that publishes. resourceid (string) Resource identifier. version (string) Specific version of the resource. Examples: >>> get_structuralresources_content_constraints_agency_resource_version_regions( ... "0001", ... "ISTAC", ... "CSM_C00010A_SIE", ... "01.000" ... ) """ path = "contentConstraints" path = '/'.join( ['contentConstraints', agencyid, resourceid, version, 'regions', regioncode] ) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_structuralresources_category_schemes_agency_resource_version_categories_id( agencyid, resourceid, version, categoryid ): """Get category schemes agency resource version categories (id) This function returns the content from ``/v1.0/categoryschemes/{agencyID}/{resourceID}/{version}/categories/{categoryID}`` Args: agencyid (string): Identifier of the agency that publishes. resourceid (string): Resource identifier. version (string): Specific version of the resource. categoryid (string): category identifier Examples: >>> get_structuralresources_category_schemes_agency_resource_version_categories_id( ... "ISTAC", ... "TEMAS_CANARIAS", ... "01.000", ... "060" ... ) >>> get_structuralresources_category_schemes_agency_resource_version_categories_id( ... "ISTAC", ... "TEMAS_CANARIAS", ... "01.000", ... "060.060_010.060_010_010" ... ) """ path = '/'.join( ['categoryschemes', agencyid, resourceid, version, 'categories', categoryid] ) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_structuralresources_category_schemes_agency_resource_version_categories( agencyid, resourceid, version, limit=25, offset=0, query='', orderby='' ): """Get category schemes agency resource version categories This function returns the content from ``/v1.0/categoryschemes/{agencyID}/{resourceID}/{version}/categories`` 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_category_schemes_agency_resource_version_categories( ... "ISTAC", ... "TEMAS_CANARIAS", ... "01.000" ... ) """ path = '/'.join(['categoryschemes', agencyid, resourceid, version, 'categories']) url = services.build_entrypoint_url( API, path, limit=limit, offset=offset, query=query, orderBy=orderby ) return services.get_content(url)
def get_indicators_systems_code_instances( indicatorsystemcode, q='', order='', limit=25, offset=0, fields='', representation='', granularity='', ): """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"' ... ) """ path = '/'.join( ['indicatorsSystems', indicatorsystemcode, 'indicatorsInstances']) url = services.build_entrypoint_url( API, path, q=q, order=order, limit=limit, offset=offset, fields=fields, representation=representation, granularity=granularity, ) return services.get_content(url)
def get_structuralresources_concept_types(): """Get concept types This function returns the content from ``/v1.0/conceptTypes`` Examples: >>> get_structuralresources_concept_types() """ path = 'conceptTypes' url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_indicators_geographic_granularities(): """Get geographic granularities This function returns a list of geographic granularities treated in the ISTAC-indicators database. For example provincial, insular or municipal granularity. Examples: >>> get_indicators_geographic_granularities() """ path = 'geographicGranularities' url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_indicators_subjects(): """Get subjects This function returns all subjects which the ISTAC classifies its statistical operations. Examples: >>> get_indicators_subjects() """ path = 'subjects' url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_indicators_time_granularities(): """Get time granularities This function returns a list of temporary granularity treated in the ISTAC data bank-indicators ordered from highest to lowest granularity. For example annual, quarterly or monthly granularity. Examples: >>> get_indicators_time_granularities() """ path = 'timeGranularities' url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_structuralresources_codelists_agency_resource_version_codes( agencyid, resourceid, version, limit=25, offset=0, query='', orderby='', openness='', order='', fields='', ): """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" ... ) """ path = '/'.join(['codelists', agencyid, resourceid, version, 'codes']) url = services.build_entrypoint_url( API, path, limit=limit, offset=offset, query=query, orderBy=orderby, openness=openness, order=order, fields=fields, ) return services.get_content(url)
def get_structuralresources_codelist_families_id(id): """Get codelist families This function allows to obtain a family of classifications in particular. Args: id (string): codelist family identificator Examples: >>> get_structuralresources_codelist_families_id('CODELIST_ID') """ path = '/'.join(['codelistfamilies', id]) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_structuralresources_variables_id(id): """Get variables (id) This function returns data from ``/v1.0/variables/{id}`` Args: id (string): Variable identifier. Examples: >>> get_structuralresources_variables_id("VR_SEXO") """ path = '/'.join(['variables', id]) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_structuralresources_variableelements_resource(variableid, resourceid): """Get variableelements resource This function returns data from ``/v1.0/variables/{variableID}/variableelements/{resourceID}`` Args: variableid (string): Resource identificator. resourceid (string): Variable identificator. Examples: >>> get_structuralresources_variableelements_resource("VR_SEXO", "FEMALE") """ path = '/'.join(['variables', variableid, 'variableelements', resourceid]) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def test_build_entrypoint_url(): url = services.build_entrypoint_url( api='indicators', path='indicators/AFILIACIONES/data', representation='GEOGRAPHICAL[35003|35005],MEASURE[ABSOLUTE]', granularity='GEOGRAPHICAL[MUNICIPALITIES|PROVINCES]', fields='-observationsMetadata', ) url_parts = urllib.parse.urlsplit(url) assert (url_parts.path == '/api/estadisticas/indicators/v1.0/indicators/AFILIACIONES/data') assert url_parts.query == ( 'representation=GEOGRAPHICAL%5B35003%7C35005%5D%2CMEASURE%5BABSOLUTE%5D&' 'granularity=GEOGRAPHICAL%5BMUNICIPALITIES%7CPROVINCES%5D&' 'fields=-observationsMetadata')
def get_indicators(q='', order='', limit=25, offset=0, fields='', representation=''): """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]" ... ) """ path = 'indicators' url = services.build_entrypoint_url( API, path, q=q, order=order, limit=limit, offset=offset, fields=fields, representation=representation, ) return services.get_content(url)
def get_indicators_code(indicatorcode): """Get indicators code This function returns the metadata that describe the characteristics of a specific indicator, allowing the compression of the measured fact; also through the data request the complete data (for all spacetime) of the indicator is provided. Args: indicatorcode (string): an indicator code Examples: >>> get_indicators_code("AFILIACIONES") >>> get_indicators_code("PARO_REGISTRADO") """ path = '/'.join(['indicators', indicatorcode]) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_indicators_systems_code(indicatorsystemcode): """Get indicators system code This function returns metadata of a system of indicators published in the ISTAC-indicators database. The indicators are simple or compound statistics, however a single indicator can rarely provide useful information about complex phenomena such as the economic situation, living conditions, schooling or others. Args: indicatorsystemcode (string): an indicator system code Examples: >>> get_indicators_systems_code("C00075H") """ path = '/'.join(['indicatorsSystems', indicatorsystemcode]) url = services.build_entrypoint_url(API, path) return services.get_content(url)
def get_statisticalresources_datasets_agency_resource_version( agencyid, resourceid, version, dim='', fields='', lang='es', as_dataframe=False): """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. as_dataframe (bool): If True, this function returns a namedtuple with: - dataframe: pandas dataframe built from API response. - codelists: mapping between codes and representations for each column. Examples: >>> get_statisticalresources_datasets_agency_resource_version( ... agencyid="ISTAC", ... resourceid="C00010A_000002", ... version="001.000" ... ) """ path = '/'.join(['datasets', agencyid, resourceid, version]) url = services.build_entrypoint_url(API, path, dim=dim, fields=fields, lang=lang) api_response = services.get_content(url) if as_dataframe: return services.build_resolved_api_response(api_response) else: return api_response
def get_structuralresources_concept_schemes_agency_resource_version_concepts( agencyid, resourceid, version, limit=25, offset=0, query='', orderby='', fields=''): """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. fields (string): Additional fields that you want to show in the answer. Examples: >>> get_structuralresources_concept_schemes_agency_resource_version_concepts( ... agencyid="ISTAC", ... resourceid="CSM_C00010A_SIE", ... version="01.000" ... ) """ path = '/'.join( ['conceptschemes', agencyid, resourceid, version, 'concepts']) url = services.build_entrypoint_url(API, path, limit=limit, offset=offset, query=query, orderBy=orderby, fields=fields) return services.get_content(url)
def get_structuralresources_codelists_agency_resource_version_codes_codeid( agencyid, resourceid, version, codeid): """Get codelists agency resource version codes (codeID) This function allows to consult a specific code of a version of a classification. Args: agencyid (string): Agency identificator. resourceid (string): Resource identificator. version (string): Specific resource version. codeid (string): Code identificator. Examples: >>> get_structuralresources_codelists_agency_resource_version_codes_codeid( "ISTAC", "CL_AREA_ES", "01.000", "ES706A01") """ path = '/'.join( ['codelists', agencyid, resourceid, version, 'codes', codeid]) url = services.build_entrypoint_url(API, path) return services.get_content(url)