de-allstar-training-clickstream-api
API package to request clickstream data
Usage
clickstream_api module contains the class datafetch.DataFetch, which can be instantiated to send api requests to fetch data from an endpoint, check a job status, or query the number of visitors per day.
In order to run the DataFetch module you must first instantiate a DataFetch object. Upon your first time running the module you will be given a prompt to enter your API key. This will save your API key to your local keyring so you will not be asked for you API key again.
Databricks
In order to run on a databricks cluster you must first add your API key to Databricks. Copy and run the code below in your terminal to add your API key.
$ databricks secrets create-scope --scope <my-scope>
$ databricks secrets put --scope <my-scope> --key <my-key> --string-value <api_key>
If running on your local machine you will be prompted to enter your API key the first time running the module. The API key will be saved to your keyring.
>>> from blend360_all_star_clickstream_api.datafetch import DataFetch
>>> data_fetch = DataFetch()
Enter your API Key:<api_key>
>>>
If the API key needs to be removed, run DataFetch.deleteAPIKey(). If the API key needs to be updated, run DataFetch.updateAPIKey().
blend360_all_star_clickstream_api.datafetch.DataFetch.fetchData
fetchData(self, start_date: datetime.date, end_date: datetime.date) -> strTriggers async job that sends data to destination s3 location
Args
start_date(datetime.date): Earliest date of clickstream data to collectend_date(datetime.date): Latest date of clickstream data to collectdestination_bucket(str): S3 bucket for data to land indestination_directory(str): Directory in S3 bucket for data to land intable_name(str): Name of table to fetchReturns:
requests.models.Response: Response object.Example:
>>> data_fetch.fetchData(start_date = datetime.date(2022, 1, 1), end_date = datetime.date(2023, 1, 1), destination_bucket= "clickstream-server", destination_directory = "poop_test") <Response [200]> >>> data_fetch.fetchData(start_date = datetime.date(2022, 1, 1), end_date = datetime.date(2023, 1, 1), destination_bucket= "clickstream-server", destination_directory = "poop_test").json() {'job_id': 12345} >>>
clickstream_api.datafetch.DataFetch.checkStatus
checkStatus(self, job_id: int) -> strChecks on the status of the S3 copy job
Args:
job_id(int): ID of S3 copy jobReturns:
requests.models.Response: Response object.Example:
>>> data_fetch.checkStatus(12345) <Response [200]> >>> data_fetch.checkStatus(12345).json() {'execution_status': 'RUNNING'} >>>
clickstream_api.datafetch.DataFetch.updateAPIKey
updateAPIKey(self)Update the API Key
Example:
>>> data_fetch.updateAPIKey() Enter your API Key:<api_key> >>>
clickstream_api.datafetch.DataFetch.deleteAPIKey
deleteAPIKey(self)Remove your API key from keyring
Example:
>>> data_fetch.deleteAPIKey() >>>
Metadata
Release files for blend360-all-star-clickstream-api 0.1.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| blend360_all_star_clickstream_api-0.1.2.tar.gz | 6.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| blend360_all_star_clickstream_api-0.1.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 12.1 kB
Release files / blend360_all_star_clickstream_api-0.1.2.tar.gz
| Download URL | blend360_all_star_clickstream_api-0.1.2.tar.gz |
|---|---|
| Size | 6.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
8e51d08e2975433f89da9a455a37c41a246afff58573d9635af8103e9d7a8f87
|
|
BLAKE2b-256 checksum How to use checksums |
4617ad867d3892d32c855df0859e5ce102423d96a76b6abefaa9bda01c7118e1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|
Release files / blend360_all_star_clickstream_api-0.1.2-py3-none-any.whl
| Download URL | blend360_all_star_clickstream_api-0.1.2-py3-none-any.whl |
|---|---|
| Size | 5.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d68419c1f540032bd3cc3989ee6fddf08eab00244bd05c67df1be3da2bb7270d
|
|
BLAKE2b-256 checksum How to use checksums |
de6097ced061ea4ed73fdd2cd6910d8613481d27f7fd7a123184aa4a60b4c557
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.9.16
|