API documentation

Annual data

Read out annual data for several locations

Annual data of all municipalities in Switzerland (incl. FSO numbers).

API: Data/Country/CH

Chapters:

API: Data/Country/CH

Function

Enables queries for Switzerland. Outputs all municipalities (incl. BFS numbers) with their public holidays and school holidays, from 1.01. - 31.12. of a year.

URL for requests

To retrieve the data, use the following URL. Please pay attention to upper case lower case.

Request parameters

With the following variables you can complete the query and control the API results.

Parameter Explanation Examples
api_key
required

Your API Key

?api_key=abc-123-def-456
year
or
jahr

Year of the requested dates

without specification: current calendar year (= default)

&year= 2025
class
or
klasse

Scope of the data

Variants:
0 = school holidays only
3 = 0 + public holidays recognised by law
4 = 0 + 3 + public and non-statutory holidays (religious, cultural) (= default)
5 = 0 + 3 + 4 + event days (e.g. Valentine's Day, Mother's Day, Advent Sundays)

&klasse=5
charset

The desired coding of the response

Variants:
UTF-8 (= default)
ISO-8859-1

&charset=iso-8859-1
format

The desired output format

Variants:
JSON (= default)
XML
CSV

&format=xml
date_format

The desired date format
The format corresponds to the date formatting of the PHP instruction date()

Variants:
Y-m-d = YYYY-MM-DD (ISO-8601) (= default)
d.m.Y = DD.MM.YYYY
Ymd = YYYYMMDD
dmY = DDMMYYYY
d.m.y = DD.MM.YY
j.n.y = D.M.YY

&date_format=d.m.Y
hl

Desired language of the output

Variants:
de = German (= default)
fr = French
it = Italian
en = English

&hl=en

Return values of the API

The contents of the API responses result from:
- the data you have subscribed to (countries, public holidays, school holidays, calendar years)
- the officially known data of the legislators
- the availability based on our research (ACTUAL situation of our database)

Please note that the output in CSV format differs.

Array         Explanation Example
interface         Version of the API  
source: href       URL to the data source (website)  
  description       Name of the data source  
copyright href       URL to the copyright holder (website)  
  description       Designation of the copyright holder  
apiName         Identification of the API Data/Country/CH
apiStatus description       Designation of the API status. For variants, see the Error messages active
date         Date of the data export 20.04.2024
request: iso       ISO country code, 2 digits CH
  year       Year of the data in the output 2015
  class       Class of the query (concerns the scope of the data) 4
  charset       Font coding of the output utf-8
  format       Output data format json
  date_format       Output date format d.m.Y
  hl       Language of issue, according to request en
results status description     Output status. For variants, see the Error messages ok
  locations location description   Designation of the geographical unit Aardorf
      type   Designation of the type of geographical unit Commune
      geoId   Geo-ID of the geographical unit. 2200
      bfsNr   FSO community number 4551
      iso   ISO country code, 2 digits CH
      iso-3166-2   Region code according to ISO 3166-2 CH-TG
      note   Special notes NEW 30.03.2023
      events   The calendar events  
        description Designation of the public holiday, or school holidays New Year´s Day
        id Unique ID of the event.
Public holidays have the same ID every year.
School holidays all have their own IDs.
1
        dateStart Date Start of the event 01.01.2015
        dateEnd Date end of the event 01.01.2015
        class Class of the event:

0 = School holidays
1 = official holiday
2 = Public holiday on a par with Sundays
3 = half-holiday (normally starting from noon)
4 = legally not recognized holiday (shops, schools, administrations mostly closed), bank holiday; for the purposes of the European Convention on the Calculation of Time Limits, this day is treated as a public holiday (Art. 5).
5 = event day
# = partially valid
2
        percent Size of affected residents / school classes in percent 100
        prov Flag for provisionally set data

0 = definitely
1 = provisional
0
        note special notes  

Error messages

Output location Error message Explanation
results: status:
results: status: description not subscribed You have not subscribed to the desired data.
Please contact our support.
apiStatus
apiStatus: description invalid usage The use of this API is not activated for you.
Please contact our support.
apiStatus: description invalid key Invalid API key.
Please check your API key.
apiStatus: description invalid referer Invalid access. Links from web pages (front-ends) are not allowed.
Set up your query so that it comes from a protected back-end.
If necessary, contact our support.
apiStatus: description inactive The API has not yet been activated for you to use.
Please try again at a later date.
apiStatus: description expired The period of use according to the contract has expired.
Contact our administration for a contract extension.

Examples

JSON

URL:
https://feiertagskalender.ch/api/Data/Country/CH/?api_key=YOUR_API_KEY&jahr=2020&date_format=d.m.Y

Response from the API:

{
	"interface": "fcal API 2.0",
	"source": {
		"href": "https://feiertagskalender.ch",
		"description": "feiertagskalender.ch"
	},
	"copyright": {
		"href": "https://psc.ch",
		"description": "psc Peter Schuetz Informatik-Dienstleistungen, CH Bern"
	},
	"apiName": "Data/Country/CH",
	"apiStatus": {
		"description": "active"
	},
	"date": "24.09.2020",
	"request": {
		"iso": "CH",
		"year": "2020",
		"class": "5",
		"charset": "utf-8",
		"format": "json",
		"date_format": "d.m.Y",
		"hl": "CH"
	},
	"results": {
		"status": {
			"description": "ok"
		},
		"locations": [{
			"description": "Aardorf",
			"type": "Gemeinde",
			"geoId": "2200",            
			"bfsNr": "4551",            
			"iso": "CH",
			"iso-3166-2": "CH-TG",
			"events": [{
				"description": "Neujahr",
				"id": "1",
				"dateStart": "01.01.2020",
				"dateEnd": "01.01.2020",
				"class": "1",
				"percent": "100",
				"prov": "0",
				"note": null
			}, {
				"description": "Berchtoldstag",
				"id": "3",
				"dateStart": "02.01.2020",
				"dateEnd": "02.01.2020",
				"class": "2",
				"percent": "100",
				"prov": "0",
				"note": null
			}, {
				"description": "Karfreitag",
				"id": "17",
				"dateStart": "10.04.2020",
				"dateEnd": "10.04.2020",
				"class": "2",
				"percent": "100",
				"prov": "0",
				"note": null
			}, {
				...
			}
		}, {
			"description": "Aarau",
			"type": "Gemeinde",
			"geoId": "3",
			"bfsNr": "4001",
			"iso": "CH",
			"iso-3166-2": "CH-AG",
			"events": [{
			...
			}]
		}]
	}
}
					

XML

URL:
https://feiertagskalender.ch/api/Data/Country/CH/?api_key=YOUR_API_KEY&jahr=2020&charset=ISO-8859-1&date_format=d.m.Y&format=xml

Response from the API:

<fcal_api>
	<interface>fcal API 2.0</interface>
	<source>
		<href>https://feiertagskalender.ch</href>
		<description>feiertagskalender.ch</description>
	</source>
	<copyright>
		<href>https://psc.ch</href>
		<description>psc Peter Schuetz Informatik-Dienstleistungen, CH Bern</description>
	</copyright>
	<apiStatus>
		<description>active</description>
	</apiStatus>
	<apiName>Data/Country/CH</apiName>
	<date>24.09.2020</date>
	<request>
		<iso>CH</iso>
		<year>2020</year>
		<class>4</class>
		<charset>ISO-8859-1</charset>
		<format>xml</format>
		<date_format>d.m.Y</date_format>
		<hl>de</hl>
	</request>
	<results>
		<status>
			<description>ok</description>
		</status>
		<locations>
			<location>
				<description>Aardorf</description>
				<type>Gemeinde</type>
				<geoId>2200</geoId>
				<bfsNr>4551</bfsNr>
				<iso>CH</iso>
				<iso-3166-2>CH-TG</iso-3166-2>
				<events>
					<event>
						<description>Neujahr</description>
						<id>1</id>
						<dateStart>01.01.2020</dateStart>
						<dateEnd>01.01.2020</dateEnd>
						<class>1</class>
						<percent>100</percent>
						<prov>0</prov>
						<note></note>
					</event>
					<event>
						<description>Berchtoldstag</description>
						<id>3</id>
						<dateStart>02.01.2020</dateStart>
						<dateEnd>02.01.2020</dateEnd>
						<class>2</class>
						<percent>100</percent>
						<prov>0</prov>
						<note></note>
					</event>
					<event>
						<description>Karfreitag</description>
						<id>17</id>
						<dateStart>10.04.2020</dateStart>
						<dateEnd>10.04.2020</dateEnd>
						<class>2</class>
						<percent>100</percent>
						<prov>0</prov>
						<note></note>
					</event>
                    ...                    
				</events>
			</location>
			<location>
				<description>Aarau</description>
				<type>Gemeinde</type>
				<geoId>3</geoId>
				<bfsNr>4001</bfsNr>
				<iso>CH</iso>
				<iso-3166-2>CH-AG</iso-3166-2>
				<events>				
					...	
				</events>
			</location>
		</locations>
	</results>
</fcal_api>                  

CSV

Aufruf:
https://feiertagskalender.ch/api/Data/Country/CH/?api_key=YOUR_API_KEY&charset=iso-8859-1&iso=DE&jahr=2020&format=csv

Response from the API:

"location";"geoId";"bfsNr";"iso";"iso_3166_2";"description";"id";"dateStart";"dateEnd";"class";"percent";"prov";"note"
"Aardorf";"2200";"4551";"CH";"CH-TG";"Neujahr";"1";"01.01.2020";"01.01.2020";"1";"100";"0";""
"Aardorf";"2200";"4551";"CH";"CH-TG";"Berchtoldstag";"3";"06.01.2020";"06.01.2020";"2";"100";"0";""
"Aardorf";"2200";"4551";"CH";"CH-TG";"Karfreitag";"17";"10.04.2020";"10.04.2020";"2";"100";"0";""
...
"Aarau";"3";"4001";"CH";"CH-AG";"Neujahr";"1";"01.01.2020";"01.01.2020";"1";"100";"0";""
...
                
Pages
Partner projects
©2003 - 2024 psc Peter Schütz Informatik Dienstleistungen, CH-Bern