{"id":16916844,"url":"https://github.com/harshil21/tgdates","last_synced_at":"2025-08-11T23:10:09.476Z","repository":{"id":133624615,"uuid":"596705737","full_name":"harshil21/TGDates","owner":"harshil21","description":"A simple, extensible and ready to use date and time picker as a Telegram web app.","archived":false,"fork":false,"pushed_at":"2023-10-09T22:45:25.000Z","size":303,"stargazers_count":15,"open_issues_count":1,"forks_count":3,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-25T13:11:24.179Z","etag":null,"topics":["datepicker","fastapi","python-telegram-bot","replit","telegram","telegram-bot","telegram-bot-api","telegram-web-app"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/harshil21.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":"harshil21","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2023-02-02T19:02:56.000Z","updated_at":"2024-12-29T09:48:05.000Z","dependencies_parsed_at":null,"dependency_job_id":"add66fc9-5725-4ed9-821e-003272c8e094","html_url":"https://github.com/harshil21/TGDates","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshil21%2FTGDates","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshil21%2FTGDates/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshil21%2FTGDates/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/harshil21%2FTGDates/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/harshil21","download_url":"https://codeload.github.com/harshil21/TGDates/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248383915,"owners_count":21094631,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["datepicker","fastapi","python-telegram-bot","replit","telegram","telegram-bot","telegram-bot-api","telegram-web-app"],"created_at":"2024-10-13T19:30:27.046Z","updated_at":"2025-04-11T11:31:12.696Z","avatar_url":"https://github.com/harshil21.png","language":"JavaScript","funding_links":["https://github.com/sponsors/harshil21"],"categories":[],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003eTGDates\u003c/h1\u003e\n\u003cp align=\"center\"\u003e\n  A simple, extensible and ready to use date and time picker as a Telegram web app.\n\u003c/p\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003ca href=\"https://t.me/tgdates_preview_bot/\"\u003e\n  \u003cimg align=\"center\" src=\"https://user-images.githubusercontent.com/37377066/216425275-2ce04b2a-1c7c-496e-ad8e-881a236ae85e.png\" style=\"width: 40%; left: 30%; position: relative; height:60%;\" alt=\"TGDates\"\u003e\n  \u003c/a\u003e\n\n\u003cbr\u003e\u003c/br\u003e\n![Uptime Robot status](https://img.shields.io/uptimerobot/status/m793631409-b2de373b4308aa5b137f491a)\n![Uptime Robot status](https://img.shields.io/uptimerobot/ratio/m793631409-b2de373b4308aa5b137f491a)\n\u003cbr\u003e\u003c/br\u003e\n[Live Demo](https://t.me/tgdates_preview_bot)\n\u003c/div\u003e\n\n## Features\n\nTGDates uses the [air-datepicker](https://github.com/t1m0n/air-datepicker) library to provide a simple and easy to use date and time picker. It is also extensible, so you can add your own custom date and time formats. TGDates provides an API so you can use most of the features of the air-datepicker library completely and easily from the Telegram bot.\n\n- No install needed! 🚀\n- Applies user's color schemes automatically ✨\n- Use any programming language or library to use this API 🎉\n\n\n## Usage and API\n\nThis API is meant for developers who want a quick and easy way to get a date and time picker in their Telegram bot. It can only be used within the `web_app` parameter of [`KeyboardButton`](https://core.telegram.org/bots/webapps#keyboard-button-mini-apps).\n\n### **Endpoint**: `https://tgdates.hoppingturtles.repl.co`\n\nPaste that URL inside a [`WebAppInfo`](https://core.telegram.org/bots/api#webappinfo) object and pass it to the `web_app` parameter of [`KeyboardButton`](https://core.telegram.org/bots/api#keyboardbutton).\n\n#### Required parameters:\n\n- None.\n\nBy default, the datepicker is shown, in English. Users can only select one date.\n\n#### Optional parameters:\n- `options`: A JSON [url encoded](https://en.wikipedia.org/wiki/Percent-encoding) object that will be passed to the air-datepicker constructor. You can find the list of options [here](https://air-datepicker.com/docs).\n\nA code snippet using this is shown in [Example use](#example-use).\n\n#### Response:\n- List[date string]: Returns a list of date strings in the format `YYYY-MM-DDTHH:MM:SS.[microseconds]Z`. The time returned is in UTC. \n\nIn Python, you can convert this to a datetime object using: `datetime.strptime(\"%Y-%m-%dT%H:%M:%S.%fZ\")`.\n\n#### Errors:\n\n- If something went wrong initializing the datepicker, the error will be shown on the screen as an alert.\n\n\n### Example use\n\nIf you are using this in Python, with the [python-telegram-bot](https://github.com/python-telegram-bot/python-telegram-bot) library, an simple example is given below (other libraries/languages should be similar):\n\n``` python\nimport json\nfrom urllib.parse import quote  # for url encoding\n...\n\nasync def send_datepicker(update: Update, _: ContextTypes.DEFAULT_TYPE) -\u003e None: \n    \"\"\"Sends the mini app as a KeyboardButton. We can customize the datepicker as well.\"\"\" \n\n    # parameters to be passed to air-datepicker (optional)\n    options = {\"range\": True, \"locale\": \"en\"}  # allow selecting range of dates\n    url = f\"https://tgdates.hoppingturtles.repl.co?options=\" + quote(json.dumps(options))  # url encoded JSON string\n    but = KeyboardButton(\"Pick a date\", web_app=WebAppInfo(url))\n    await update.message.reply_text(\"Choose\", reply_markup=ReplyKeyboardMarkup.from_button(but))\n...\n```\n\nThe full example is shown in [host.py](https://github.com/harshil21/TGDates/blob/main/host.py). You can see a live demo of this [here](https://t.me/tgdates_preview_bot).\n\nSome notes:\n\n- The default locale is `en`. To change the locale, pass the two letter locale code to the `locale` key in the `options` parameter. The list of supported locales can be found [here](https://github.com/t1m0n/air-datepicker/tree/v3/src/locale).\n- If you have the time picker enabled, the time the user enters in their web app is with respect to their time zone. However, the time returned from the web app will be in UTC.\n- To use *only* the timepicker, pass `{onlyTimepicker: True, timepicker: True}` to the `options` parameter. See https://github.com/t1m0n/air-datepicker/issues/523\n\n### Self hosting\n\nIf you would like to host this webapp yourself, you can do so. This is recommended if you want to make code changes to this repository.\n\n1. Have [node](https://nodejs.org/en/download), npm, [webpack](https://webpack.js.org/guides/installation/), and [python](https://python.org/downloads) installed. This tutorial uses Python 3.11, although other python versions 3.7+ should work as well.\n2. Clone this repository.\n```bash\ngit clone https://github.com/harshil21/TGDates.git\n```\n3. Install all the requirements from [`requirements.txt`](https://github.com/harshil21/TGDates/blob/main/requirements.txt) and [`package.json`](https://github.com/harshil21/TGDates/blob/main/package.json).\n\n```bash\ncd TGDates/ \u0026\u0026 pip install -r requirements.txt \u0026\u0026 npm install -D\n```\n\n4. Preferably have a domain name and a SSL certificate, because even though [Telegram says](https://core.telegram.org/bots/webapps#testing-mini-apps) you can test your webapp without HTTPS, the Android client will refuse connections to non-HTTPS sites even in the test servers (tested in Feb 23', may have changed by now).\n5. A bot token. You can get one by talking to [@BotFather](https://t.me/BotFather).\n6. Populate your `.env` file in the root of the repository with the values:\n```bash\nTOKEN=\"your bot token\"\nHOST=\"your hostname\"\nPORT=\"your port to run the server on\"\nSSL_CERT=\"Optional: path to your SSL certificate\"\nSSL_KEY=\"Optional: path to your SSL key\"\n```\n\n7. Now run `npx webpack` in the root directory. This will create a `dist` directory with all the files needed to run the webapp.\n8. Run the web server by running `python host.py`. This will start a web server on your selected port. You may need to run this as root if you want to bind to a privileged port (port 80, 443, etc.).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshil21%2Ftgdates","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fharshil21%2Ftgdates","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fharshil21%2Ftgdates/lists"}