Skip to content

A simple and small API for any advent-caneldar-website to fetch some kind of data

License

Notifications You must be signed in to change notification settings

Trickfilm400/advent-calendar-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

advent-calendar-api

This is a project to get any kind of json data for any advent-calendar website or something else.

You can put your data in a json array and then, depending on the day, you get the entries of the array until this day

This project is designed to be configured for different data storages in the future, for example mysql, instead of json files

Installation

  1. put all these files in a web-directory
  2. the index.php file is the main entrypoint, so point every single request to this file!
  3. For jsonFile usage:
    1. in the storage folder put a file named advent.json (will be auto-generated on the first request, if it didn't exist)
    2. the json file has the following structure (you can configure objects, strings, etc.):
{
  "data": [
    {"key": 123},
    {"key2": "value2"},
    {"key3": {"object": 1, "test": 2}},
    {"key4": "value4", "key5": "value5"}
  ]
}

Usage

  • Make a request and you get the following result:

Example for days before december (like november, so your calendar can get live without any dors opend)

{
  "data": []
}

December, 1st:

{
  "data": [
    {"key": "value"}
  ]
}

December, 29th (if you have configured enough data in you config):

{
  "data": [
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"},
    {"key": "value"}
  ]
}

overwrite Day for testing

  • add an overwriteDay key-value pair to the root element of the json
{
   "overwriteDay": 24, 
   "data": [] //data from above
}

Questions? Open an issue

© Trickfilm400 2021-2022

About

A simple and small API for any advent-caneldar-website to fetch some kind of data

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages