{"id":15501678,"url":"https://github.com/genesis331/kagglestconnection","last_synced_at":"2025-04-10T21:56:26.736Z","repository":{"id":184939895,"uuid":"672257029","full_name":"genesis331/KaggleStConnection","owner":"genesis331","description":"st.connection implementation for Kaggle Public API","archived":false,"fork":false,"pushed_at":"2023-12-08T03:35:17.000Z","size":31,"stargazers_count":1,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-10T21:56:13.174Z","etag":null,"topics":["api","connection-hackathon","kaggle","python","streamlit"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/genesis331.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-07-29T13:02:16.000Z","updated_at":"2025-02-07T04:23:36.000Z","dependencies_parsed_at":"2023-12-03T10:22:03.550Z","dependency_job_id":"576d06c1-12d8-438d-bd86-6eff042fd623","html_url":"https://github.com/genesis331/KaggleStConnection","commit_stats":{"total_commits":18,"total_committers":3,"mean_commits":6.0,"dds":"0.16666666666666663","last_synced_commit":"f4f681f79cc702f3047c470e614bd892975848a1"},"previous_names":["genesis331/kagglestconnection"],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genesis331%2FKaggleStConnection","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genesis331%2FKaggleStConnection/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genesis331%2FKaggleStConnection/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/genesis331%2FKaggleStConnection/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/genesis331","download_url":"https://codeload.github.com/genesis331/KaggleStConnection/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248305839,"owners_count":21081574,"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":["api","connection-hackathon","kaggle","python","streamlit"],"created_at":"2024-10-02T09:05:18.432Z","updated_at":"2025-04-10T21:56:26.717Z","avatar_url":"https://github.com/genesis331.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# KaggleStConnection Documentation\n\n**KaggleStConnection** is a Streamlit connection class that connects to Kaggle API. Better than the default [Kaggle API](https://www.kaggle.com/docs/api), **KaggleStConnection** automates the reading of a specific data file from your desired dataset found on Kaggle.\n\nYou can view the source GitHub repository for the connection class and the demo app in the links below:\n\n* [KaggleStConnection](https://github.com/genesis331/KaggleStConnection)\n* [KaggleStConnectionDemo](https://github.com/LimJY03/KaggleStConnectionDemo)\n\nYou may access the app at [this link](https://kagglestconnection.streamlit.app/).\n\n\u003cimg width=\"1440\" alt=\"Screenshot 2023-12-08 at 11 26 05 AM\" src=\"https://github.com/genesis331/KaggleStConnection/assets/22348410/3a0edf86-b80e-4d8d-923e-03e5fcc80f13\"\u003e\n\n\n### Package Installation\n\nTo install **KaggleStConnection** in your local machine, install the package with the code below in the terminal and you are ready to go.\n\n```sh\npip install kaggle-st-connection\n```\n\n### Initializing KaggleStConnection\n\nAfter you have installed the **KaggleStConnection** package in the step above, you can start to initialize a connection to the Kaggle API and obtain a connection object with the following code.\n\n```py\n# Package imports\nfrom KaggleAPIConnection import KaggleAPIConnection\nimport streamlit as st\n\n# Initialize connection\nconn = st.connection(\"kaggle\", type=KaggleAPIConnection)\n\n# Obtain connection object\ncursor = conn.cursor()\n```\n\nYou can use the connection object `cursor` to call some KaggleAPI methods like `dataset_list()` and many more depending on your use cases.\n\n### Querying Data From Kaggle Datasets\n\nWe can use the `query()` method and specify the Kaggle dataset reference in the format of `'[owner_slug]/[dataset_slug]'` as the method argument.\n\nWe can additionally use the `file` keyword argument to specify the dataset file to query from. By default, the first file in the dataset will be queried.\n\n```py\n# Using the previous initialized connection object `conn`\ndata = conn.query(\n    'kritikseth/us-airbnb-open-data',   # Dataset ref\n    file='AB_US_2023.csv'               # Optional file to open\n)\n```\n\nIn this case, we set the parameter `file` to `'AB_US_2023.csv'` so that we will obtain the desired latest data for our sample visualization shown below.\n\n### Configuring Kaggle API Key\n\nBefore the above code can work, we will need to specify the API key during the initialization of the connection. The following quote the steps to obtain your API key on [kaggle.com](https://www.kaggle.com/) from the Kaggle Documentation.\n\n\u003e **🗨 Kaggle's Public API Documentation ([Read Here](https://www.kaggle.com/docs/api))**\n\u003e \u003cbr\u003eIn order to use Kaggle's public API, you must first authenticate using an API token. Go to the 'Account' tab of your user profile and select 'Create New Token'. This will trigger the download of `kaggle.json`, a file containing your API credentials.\n\nTo use your API keys in Streamlit, you can either:\n\n* Go to your **Project Root (~)** and create a `.kaggle` folder and place your `kaggle.json` inside the folder.\n* Go to your **Workspace Root** and create a `.streamlit` folder and create a `secrets.toml` file, then enter the following in the file:\n  ```toml\n  [connections.kaggle]\n  kaggle_username='\u003cUSERNAME\u003e'\n  kaggle_key='\u003cAPI_KEY\u003e'\n  ```\n  Replace the `\u003cUSERNAME\u003e` and the `\u003cAPI_KEY\u003e` with that in your `kaggle.json` file.\n* **[NOT RECOMMENDED FOR PUBLIC DEPLOYMENT]** Specify the `kaggle_username` and `kaggle_key` optional parameter during the initialization of the connection with `st.connection`. An example of this use case is shown below:\n  ```py\n  conn = st.connection(\n      'kaggle', \n      type=KaggleAPIConnection,\n      kaggle_username='\u003cUSERNAME\u003e',\n      kaggle_key='\u003cAPI_KEY\u003e'\n  )\n  ```\n  Similarly to the previous bullet, replace  the `\u003cUSERNAME\u003e` and the `\u003cAPI_KEY\u003e` with that in your `kaggle.json` file.\n\nYou can read more about secrets management in [Streamlit's secrets management documentation](https://docs.streamlit.io/streamlit-community-cloud/get-started/deploy-an-app/connect-to-data-sources/secrets-management).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenesis331%2Fkagglestconnection","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fgenesis331%2Fkagglestconnection","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fgenesis331%2Fkagglestconnection/lists"}