Sign inSign up

jah118/holiday-api-wrapper

By jah118

•Updated 9 days ago

Holiday API is a Wrapper for Salling's holiday API, fetching Danish holiday data and extends it.

Image
Integration & delivery
API management
Web servers
0

1.6K

jah118/holiday-api-wrapper repository overview

⁠Holiday API wrapper

The Holiday API is a data api wrapper for the Salling holiday API⁠. It fetches holiday data from the Salling service and returns it to the client. The data includes both national and non-national holidays.

It can be set up automatically to pull data from the Salling Group API at a specified interval, or an external cron job can be used to call it.

To use internal scheduling, the CRON_ENABLED environment variable must be set to true and then CRON_PULL_SALLING can be used to set the cron expression for pulling data.

Here a default of 0 0 4 * * * is set, which will default 12 months of holidays at 4 AM every day. Or you can set custom range for 10 years (5 years before and after today) by setting the HOLIDAY_URI_CUSTOM_RANGE environment variable to https://api.sallinggroup.com/v1/holidays/?startDate=2011-01-02&endDate=2028-09-09 then this will be used instead of the default 12 months.

⁠API Documentation

The API documentation for the salling api can be found here⁠, which provides further details on the Salling API terms and usage.

TODO—there will be an openapi included for each release for quick api scaffold against this small API service.

A postman collection can be found here⁠

⁠Important Notice Regarding Data Usage

This project integrates with the Salling Group API. The data retrieved and processed by this project is subject to Salling Group's terms and conditions⁠.
As a user of this software, you are required to comply with those terms when using the Salling Group data.

Specifically:

  • The data provided by Salling Group may only be used for purposes aligned with their terms.
  • Redistribution or modification of their data requires Salling Group’s written consent.
  • Ensure you are familiar with and follow their policies, this services aims to wrap their data to limit cals to them and extend on ways to check on holidays.

⁠How to Use / Install

The API wrapper can be run through docker. Follow the steps below to set it up:

⁠Release build latest
  1. docker pull jah118/holiday-api-wrapper
    
  2. Run the Docker container:

    docker run -d -p 8080:8080 -e HOLIDAY_API_TOKEN=Your_Api_key --name holidayapi-wrapper holidayapi-wrapper
    
  3. Configuration (Optional):

  • If your project uses environment variables, mount an .env file:
    docker run -d -p 8080:8080 --env-file .env --name holidayapi-wrapper holidayapi-wrapper
    
⁠Local run
  1. Clone the repository:

    git clone <repository-url>
    cd <repository-folder>
    
  2. Build the Docker image (if a custom build is required):

    docker build -t holidayapi-wrapper .
    
  3. Run the Docker container:

    docker run -d -p <host-port>:8080 -e HOLIDAY_API_TOKEN=Your_Api_key --name holidayapi-wrapper holidayapi-wrapper
    
  4. Configuration (Optional):

    • If your project uses environment variables, mount an .env file:
      docker run -d -p <host-port>:8080 --env-file .env --name api-wrapper-cache api-wrapper-cache
      
  5. Access the API wrapper/Cache: Use http://localhost:<host-port> to access the running service.

Replace <repository-url>, <repository-folder>, <host-port>, and <container-port> with appropriate values for your setup.


⁠Configuration and Environment Variables

To configure the application, you can use the following environment variables. These options allow flexibility and customization depending on your deployment environment. Default values are provided where applicable.

Environment VariableDefault ValueDescription
Server Configuration
SERVER_PORT8080Port on which the application server runs.
SERVER_COMPRESSION_ENABLEDfalseEnables GZIP compression for HTTP responses.
Management Configuration
MANAGEMENT_SERVER_PORT8080Port for management endpoints (health, metrics, etc.).
MANAGEMENT_ENDPOINTS_INCLUDEhealth,prometheus,openapi,readinessState,info,probes,metricsComma-separated list of management endpoints to expose.
Security Configuration
SECURITY_STATEfalseDetermines whether the security features of the service are enabled.
APIKEYNotSetUseDefaultDefines the API key for authentication; if not set, a default key will be used.
Data Source Configuration
SPRING_DATASOURCE_URLjdbc:h2:mem:holidayapiJDBC URL for the data source.
SPRING_DATASOURCE_USERNAMEsaUsername for the data source.
SPRING_DATASOURCE_PASSWORDpasswordPassword for the data source.
H2_CONSOLE_ENABLEDfalseEnables H2 database console (disable in production).
JPA/Hibernate Configuration
SPRING_JPA_HIBERNATE_DDL_AUTOcreate-dropHibernate DDL auto mode (create, update, validate, etc.).
SPRING_JPA_PROPERTIES_HIBERNATE_FORMAT_SQLfalseFormats SQL statements in logs for better readability.
SPRING_JPA_SHOW_SQLfalseShows SQL statements in logs.
SPRING_JPA_OPEN_IN_VIEWfalseEnables Open Session in View pattern.
Holiday API Configuration
HOLIDAY_API_TOKEN-Token used to access the external Holiday API (required).
HOLIDAY_BASE_URIhttps://api.sallinggroup.com/v1/holidaysBase URI for fetching holiday data from Salling Group API.
HOLIDAY_URI_CUSTOM_RANGEnullCustom URI for fetching holidays within a specific date range.
HOLIDAY_ENABLE_CUSTOM_RANGEfalseEnables 10-year range (5 years before/after current date) when custom range not specified.
HOLIDAY_URI_COUNTRYdkCountry code for the Salling Group API (dk for Denmark).
HOLIDAYAPI_SHOULD_RESET_EACH_TIMEfalseIndicates if data should reset every time the application runs.
HOLIDAYAPI_USE_MOCK_DATAfalseUses mock data instead of calling external API (for testing).
Application Configuration
APP_PULL_DATA_AT_STARTUPfalseDetermines whether the application should pull data during startup.
Cron Job Configuration
CRON_PULL_SALLING0 0 4 * * *Cron expression for pulling data from Salling Group's Holiday API (daily at 4 AM).
CRON_ENABLEDfalseToggles cron jobs on or off.
Swagger Configuration
SWAGGER_DOC_ENABLEDtrueEnables Swagger API documentation.
SWAGGER_UI_PATH/swagger-ui.htmlThe path where Swagger UI can be accessed.
Logging Configuration
LOGGING_LEVEL_SPRING_FRAMEWORKINFOLogging level for Spring Framework.
LOGGING_LEVEL_HOLIDAYAPIINFOLogging level for Holiday API-related logs.

⁠Notes
  • Environment variables can be defined in the application .env file or configured directly in the environment where the application is running.
  • For settings that do not have an environment variable, their defaults will be used.
  • Make sure to store sensitive environment variables such as SPRING_DATASOURCE_PASSWORD and HOLIDAY_API_TOKEN in a secure manner.
  • The HOLIDAY_API_TOKEN is required for the application to function properly with the Salling Group API.
  • When SECURITY_STATE is enabled, ensure you set a secure APIKEY value instead of using the default.
  • The H2 console should be disabled (H2_CONSOLE_ENABLED=false) in production environments for security reasons.

Tag summary

Content type

Image

Digest

sha256:14f33edda…

Size

112.8 MB

Last updated

3 months ago

docker pull jah118/holiday-api-wrapper