diff --git a/Brevo/Brevo_Add_contacts_to_list.ipynb b/Brevo/Brevo_Add_contacts_to_list.ipynb new file mode 100644 index 0000000000..196a5ec7b4 --- /dev/null +++ b/Brevo/Brevo_Add_contacts_to_list.ipynb @@ -0,0 +1,269 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "latin-packing", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Sendinblue.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-wilson", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Brevo - Add contacts to list" + ] + }, + { + "cell_type": "markdown", + "id": "religious-programmer", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #brevo #contacts #lists #create #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "1fe9f56e-561c-4f52-aef8-b861c9462107", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "4c1a2bcc-e330-48dc-b1fd-a19b6734c4ac", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-05-30 (Created: 2024-05-30)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook add contacts to a list in Brevo." + ] + }, + { + "cell_type": "markdown", + "id": "distinguished-truth", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "numeric-mediterranean", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "potential-surfing", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests" + ] + }, + { + "cell_type": "markdown", + "id": "f0c7a5bb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Brevo API Key\n", + "- `list_id`: Brevo List ID\n", + "- `emails`: List of emails to be added" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7f66f6e-03ec-46e2-92fa-df362a3f9b7f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = \"YOUR_BREVO_API_KEY\"\n", + "list_id = 20\n", + "emails = []" + ] + }, + { + "cell_type": "markdown", + "id": "registered-showcase", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "2efabd94-e17c-4f16-bfa0-7ff87d297048", + "metadata": {}, + "source": [ + "### Get contacts in a list" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e523907a-d34e-421d-a397-63b72880f128", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def add_contact_to_list(api_key, list_id, emails):\n", + " url = f\"https://api.brevo.com/v3/contacts/lists/{list_id}/contacts/add\"\n", + " payload = {\"emails\": emails}\n", + " headers = {\n", + " \"api-key\": api_key,\n", + " \"accept\": \"application/json\",\n", + " \"content-type\": \"application/json\"\n", + " }\n", + " res = requests.post(url, json=payload, headers=headers)\n", + " if res.status_code == 200:\n", + " return res.json()\n", + " \n", + "result = add_contact_to_list(api_key, list_id, emails)" + ] + }, + { + "cell_type": "markdown", + "id": "lonely-pacific", + "metadata": { + "execution": { + "iopub.execute_input": "2021-07-02T23:32:10.789097Z", + "iopub.status.busy": "2021-07-02T23:32:10.788829Z", + "iopub.status.idle": "2021-07-02T23:32:10.796900Z", + "shell.execute_reply": "2021-07-02T23:32:10.796358Z", + "shell.execute_reply.started": "2021-07-02T23:32:10.789033Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "ef2a8116-b01c-4041-8a6c-4d9d57578e53", + "metadata": {}, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35c1a464-d4e5-44df-bcbb-bd62e1f01187", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fba4876d-d51c-47eb-bb0e-ba9e876ef115", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "naas": { + "notebook_id": "dd7e259333a94870bff986f6e4f3d3e1875f6fd02fbe6c6fccacd81d7fbc1336", + "notebook_path": "Sendinblue/Sendinblue_Get_no_of_undelivered_emails.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Brevo/Brevo_Create_contact.ipynb b/Brevo/Brevo_Create_contact.ipynb new file mode 100644 index 0000000000..d8ea25d068 --- /dev/null +++ b/Brevo/Brevo_Create_contact.ipynb @@ -0,0 +1,280 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "latin-packing", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Sendinblue.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-wilson", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Brevo - Create a contact" + ] + }, + { + "cell_type": "markdown", + "id": "religious-programmer", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #brevo #contacts #create #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "1fe9f56e-561c-4f52-aef8-b861c9462107", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "4c1a2bcc-e330-48dc-b1fd-a19b6734c4ac", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-05-30 (Created: 2024-05-30)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook creates a contact in Brevo." + ] + }, + { + "cell_type": "markdown", + "id": "0fb6cf1e-0e97-40dd-ac63-d0b1fd23faf9", + "metadata": {}, + "source": [ + "**References:**\n", + "- [Brevo Documentation](https://developers.brevo.com/reference/createcontact)" + ] + }, + { + "cell_type": "markdown", + "id": "distinguished-truth", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "numeric-mediterranean", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "potential-surfing", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests" + ] + }, + { + "cell_type": "markdown", + "id": "f0c7a5bb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Brevo API Key\n", + "- `payload`: Payload" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7f66f6e-03ec-46e2-92fa-df362a3f9b7f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = \"YOUR_BREVO_API_KEY\"\n", + "payload = {\n", + " \"email\": \"\",\n", + " \"attributes\": {},\n", + " \"listIds\": [],\n", + "}" + ] + }, + { + "cell_type": "markdown", + "id": "registered-showcase", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "2efabd94-e17c-4f16-bfa0-7ff87d297048", + "metadata": {}, + "source": [ + "### Create a contact" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e523907a-d34e-421d-a397-63b72880f128", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def create_contact(api_key, data):\n", + " url = \"https://api.brevo.com/v3/contacts\"\n", + " headers = {\n", + " \"api-key\": api_key,\n", + " \"accept\": \"application/json\",\n", + " \"content-type\": \"application/json\"\n", + " }\n", + " res = requests.post(url, headers=headers, json=payload)\n", + " if res.status_code == 200:\n", + " return res.json()\n", + "\n", + "result = create_contact(api_key, contact_data)\n", + "print(result)" + ] + }, + { + "cell_type": "markdown", + "id": "lonely-pacific", + "metadata": { + "execution": { + "iopub.execute_input": "2021-07-02T23:32:10.789097Z", + "iopub.status.busy": "2021-07-02T23:32:10.788829Z", + "iopub.status.idle": "2021-07-02T23:32:10.796900Z", + "shell.execute_reply": "2021-07-02T23:32:10.796358Z", + "shell.execute_reply.started": "2021-07-02T23:32:10.789033Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "ef2a8116-b01c-4041-8a6c-4d9d57578e53", + "metadata": {}, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35c1a464-d4e5-44df-bcbb-bd62e1f01187", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fba4876d-d51c-47eb-bb0e-ba9e876ef115", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "naas": { + "notebook_id": "dd7e259333a94870bff986f6e4f3d3e1875f6fd02fbe6c6fccacd81d7fbc1336", + "notebook_path": "Sendinblue/Sendinblue_Get_no_of_undelivered_emails.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Brevo/Brevo_Get_all_the_lists.ipynb b/Brevo/Brevo_Get_all_the_lists.ipynb new file mode 100644 index 0000000000..89c7d9ebd0 --- /dev/null +++ b/Brevo/Brevo_Get_all_the_lists.ipynb @@ -0,0 +1,273 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "latin-packing", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Sendinblue.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-wilson", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Brevo - Get all the lists" + ] + }, + { + "cell_type": "markdown", + "id": "religious-programmer", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #brevo #contacts #lists #get #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "1fe9f56e-561c-4f52-aef8-b861c9462107", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "4c1a2bcc-e330-48dc-b1fd-a19b6734c4ac", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-05-30 (Created: 2024-05-30)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook get all the lists in Brevo." + ] + }, + { + "cell_type": "markdown", + "id": "0fb6cf1e-0e97-40dd-ac63-d0b1fd23faf9", + "metadata": {}, + "source": [ + "**References:**\n", + "- [Brevo Documentation](https://developers.brevo.com/reference/getlists-1)" + ] + }, + { + "cell_type": "markdown", + "id": "distinguished-truth", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "numeric-mediterranean", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "potential-surfing", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "id": "f0c7a5bb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Brevo API Key" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7f66f6e-03ec-46e2-92fa-df362a3f9b7f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = \"YOUR_BREVO_API_KEY\"" + ] + }, + { + "cell_type": "markdown", + "id": "registered-showcase", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "f93103ca-e113-422c-88ef-f7993955cf3f", + "metadata": {}, + "source": [ + "### Get all lists" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "1741edcb-78c1-49a2-b913-b02104beeffa", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def get_all_lists(api_key):\n", + " url = \"https://api.brevo.com/v3/contacts/lists\"\n", + "\n", + " headers = {\n", + " \"accept\": \"application/json\",\n", + " \"api-key\": api_key\n", + " }\n", + "\n", + " res = requests.get(url, headers=headers)\n", + " res.raise_for_status()\n", + "\n", + " if res.status_code == 200:\n", + " return res.json()\n", + " \n", + "\n", + "data = get_all_lists(api_key)\n", + "data.get(\"lists\")[0]" + ] + }, + { + "cell_type": "markdown", + "id": "lonely-pacific", + "metadata": { + "execution": { + "iopub.execute_input": "2021-07-02T23:32:10.789097Z", + "iopub.status.busy": "2021-07-02T23:32:10.788829Z", + "iopub.status.idle": "2021-07-02T23:32:10.796900Z", + "shell.execute_reply": "2021-07-02T23:32:10.796358Z", + "shell.execute_reply.started": "2021-07-02T23:32:10.789033Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "ef2a8116-b01c-4041-8a6c-4d9d57578e53", + "metadata": {}, + "source": [ + "### Display results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35c1a464-d4e5-44df-bcbb-bd62e1f01187", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "df = pd.DataFrame(data.get(\"lists\"))\n", + "print(\"Rows:\", len(df))\n", + "df" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "naas": { + "notebook_id": "dd7e259333a94870bff986f6e4f3d3e1875f6fd02fbe6c6fccacd81d7fbc1336", + "notebook_path": "Sendinblue/Sendinblue_Get_no_of_undelivered_emails.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Brevo/Brevo_Get_contact.ipynb b/Brevo/Brevo_Get_contact.ipynb new file mode 100644 index 0000000000..c1a195e1ad --- /dev/null +++ b/Brevo/Brevo_Get_contact.ipynb @@ -0,0 +1,280 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "latin-packing", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Sendinblue.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-wilson", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Brevo - Get a contact's details" + ] + }, + { + "cell_type": "markdown", + "id": "religious-programmer", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #brevo #contacts #get #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "1fe9f56e-561c-4f52-aef8-b861c9462107", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "4c1a2bcc-e330-48dc-b1fd-a19b6734c4ac", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-05-30 (Created: 2024-05-30)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook get a contact's details in Brevo." + ] + }, + { + "cell_type": "markdown", + "id": "0fb6cf1e-0e97-40dd-ac63-d0b1fd23faf9", + "metadata": {}, + "source": [ + "**References:**\n", + "- [Brevo Documentation](https://developers.brevo.com/reference/getcontactinfo-1)" + ] + }, + { + "cell_type": "markdown", + "id": "distinguished-truth", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "numeric-mediterranean", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "potential-surfing", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests" + ] + }, + { + "cell_type": "markdown", + "id": "f0c7a5bb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Brevo API Key\n", + "- `contact_id`: Contact ID" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7f66f6e-03ec-46e2-92fa-df362a3f9b7f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = \"YOUR_BREVO_API_KEY\"\n", + "contact_id = \"\"" + ] + }, + { + "cell_type": "markdown", + "id": "registered-showcase", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "2efabd94-e17c-4f16-bfa0-7ff87d297048", + "metadata": {}, + "source": [ + "### Get a contact" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e523907a-d34e-421d-a397-63b72880f128", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def get_contact(\n", + " api_key,\n", + " contact_id,\n", + "):\n", + " # Init\n", + " data = []\n", + " url = f\"https://api.brevo.com/v3/contacts/{contact_id}\"\n", + " headers = {\n", + " \"accept\": \"application/json\",\n", + " \"api-key\": api_key\n", + " }\n", + " res = requests.get(url, headers=headers)\n", + " if res.status_code == 200:\n", + " return res.json()\n", + "\n", + "result = get_contact(api_key, contact_id)\n", + "result" + ] + }, + { + "cell_type": "markdown", + "id": "lonely-pacific", + "metadata": { + "execution": { + "iopub.execute_input": "2021-07-02T23:32:10.789097Z", + "iopub.status.busy": "2021-07-02T23:32:10.788829Z", + "iopub.status.idle": "2021-07-02T23:32:10.796900Z", + "shell.execute_reply": "2021-07-02T23:32:10.796358Z", + "shell.execute_reply.started": "2021-07-02T23:32:10.789033Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "ef2a8116-b01c-4041-8a6c-4d9d57578e53", + "metadata": {}, + "source": [ + "### Display result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35c1a464-d4e5-44df-bcbb-bd62e1f01187", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "result" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "945e89c9-14c3-470c-a1d7-6bc9d9404197", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "naas": { + "notebook_id": "dd7e259333a94870bff986f6e4f3d3e1875f6fd02fbe6c6fccacd81d7fbc1336", + "notebook_path": "Sendinblue/Sendinblue_Get_no_of_undelivered_emails.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Brevo/Brevo_Get_contacts.ipynb b/Brevo/Brevo_Get_contacts.ipynb new file mode 100644 index 0000000000..55f370009e --- /dev/null +++ b/Brevo/Brevo_Get_contacts.ipynb @@ -0,0 +1,296 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "latin-packing", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Sendinblue.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-wilson", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Brevo - Get all the contacts" + ] + }, + { + "cell_type": "markdown", + "id": "religious-programmer", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #brevo #contacts #get #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "1fe9f56e-561c-4f52-aef8-b861c9462107", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "4c1a2bcc-e330-48dc-b1fd-a19b6734c4ac", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-05-30 (Created: 2024-05-30)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook get all the contacts in Brevo." + ] + }, + { + "cell_type": "markdown", + "id": "0fb6cf1e-0e97-40dd-ac63-d0b1fd23faf9", + "metadata": {}, + "source": [ + "**References:**\n", + "- [Brevo Documentation](https://developers.brevo.com/reference/getcontacts-1)" + ] + }, + { + "cell_type": "markdown", + "id": "distinguished-truth", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "numeric-mediterranean", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "potential-surfing", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "id": "f0c7a5bb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Brevo API Key" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7f66f6e-03ec-46e2-92fa-df362a3f9b7f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = \"YOUR_BREVO_API_KEY\"" + ] + }, + { + "cell_type": "markdown", + "id": "registered-showcase", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "2efabd94-e17c-4f16-bfa0-7ff87d297048", + "metadata": {}, + "source": [ + "### Get all the contacts" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e523907a-d34e-421d-a397-63b72880f128", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def get_contacts(\n", + " api_key,\n", + " limit=100,\n", + " endpoint=\"contacts\"\n", + "):\n", + " # Init\n", + " data = []\n", + " url = f\"https://api.brevo.com/v3/contacts/\"\n", + " headers = {\n", + " \"accept\": \"application/json\",\n", + " \"api-key\": api_key\n", + " }\n", + " offset = 0\n", + " while True:\n", + " params = {\n", + " \"limit\": limit,\n", + " \"offset\": offset\n", + " }\n", + " res = requests.get(url, headers=headers, params=params)\n", + " if res.status_code == 200:\n", + " result = res.json().get(endpoint)\n", + " data.extend(result)\n", + " else:\n", + " break\n", + " if len(result) == 0 or len(result) < limit:\n", + " break\n", + " else:\n", + " offset += limit\n", + " return data\n", + "\n", + "data = get_contacts(api_key)\n", + "data[0]" + ] + }, + { + "cell_type": "markdown", + "id": "lonely-pacific", + "metadata": { + "execution": { + "iopub.execute_input": "2021-07-02T23:32:10.789097Z", + "iopub.status.busy": "2021-07-02T23:32:10.788829Z", + "iopub.status.idle": "2021-07-02T23:32:10.796900Z", + "shell.execute_reply": "2021-07-02T23:32:10.796358Z", + "shell.execute_reply.started": "2021-07-02T23:32:10.789033Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "ef2a8116-b01c-4041-8a6c-4d9d57578e53", + "metadata": {}, + "source": [ + "### Display results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35c1a464-d4e5-44df-bcbb-bd62e1f01187", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "df = pd.DataFrame(data)\n", + "print(\"Rows:\", len(df))\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fba4876d-d51c-47eb-bb0e-ba9e876ef115", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "naas": { + "notebook_id": "dd7e259333a94870bff986f6e4f3d3e1875f6fd02fbe6c6fccacd81d7fbc1336", + "notebook_path": "Sendinblue/Sendinblue_Get_no_of_undelivered_emails.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/Brevo/Brevo_Get_contacts_list.ipynb b/Brevo/Brevo_Get_contacts_list.ipynb new file mode 100644 index 0000000000..79065e27a5 --- /dev/null +++ b/Brevo/Brevo_Get_contacts_list.ipynb @@ -0,0 +1,299 @@ +{ + "cells": [ + { + "cell_type": "markdown", + "id": "latin-packing", + "metadata": { + "execution": { + "iopub.execute_input": "2021-02-23T14:22:16.610471Z", + "iopub.status.busy": "2021-02-23T14:22:16.610129Z", + "iopub.status.idle": "2021-02-23T14:22:16.627784Z", + "shell.execute_reply": "2021-02-23T14:22:16.626866Z", + "shell.execute_reply.started": "2021-02-23T14:22:16.610384Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "\"Sendinblue.png\"" + ] + }, + { + "cell_type": "markdown", + "id": "compressed-wilson", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "# Brevo - Get contacts from list" + ] + }, + { + "cell_type": "markdown", + "id": "religious-programmer", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Tags:** #brevo #contacts #lists #snippet" + ] + }, + { + "cell_type": "markdown", + "id": "1fe9f56e-561c-4f52-aef8-b861c9462107", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Author:** [Florent Ravenel](https://www.linkedin.com/in/florent-ravenel/)" + ] + }, + { + "cell_type": "markdown", + "id": "4c1a2bcc-e330-48dc-b1fd-a19b6734c4ac", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "**Last update:** 2024-05-30 (Created: 2024-05-30)" + ] + }, + { + "cell_type": "markdown", + "id": "naas-description", + "metadata": { + "papermill": {}, + "tags": [ + "description" + ] + }, + "source": [ + "**Description:** This notebook get contacts from a list in Brevo." + ] + }, + { + "cell_type": "markdown", + "id": "0fb6cf1e-0e97-40dd-ac63-d0b1fd23faf9", + "metadata": {}, + "source": [ + "**References:**\n", + "- [Brevo Documentation](https://developers.brevo.com/reference/getcontactsfromlist)" + ] + }, + { + "cell_type": "markdown", + "id": "distinguished-truth", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Input" + ] + }, + { + "cell_type": "markdown", + "id": "numeric-mediterranean", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Import libraries" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "potential-surfing", + "metadata": { + "papermill": {}, + "tags": [] + }, + "outputs": [], + "source": [ + "import requests\n", + "import pandas as pd" + ] + }, + { + "cell_type": "markdown", + "id": "f0c7a5bb", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "### Setup variables\n", + "- `api_key`: Brevo API Key\n", + "- `list_id`: Brevo List ID" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "b7f66f6e-03ec-46e2-92fa-df362a3f9b7f", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "api_key = \"YOUR_BREVO_API_KEY\"\n", + "list_id = 20" + ] + }, + { + "cell_type": "markdown", + "id": "registered-showcase", + "metadata": { + "papermill": {}, + "tags": [] + }, + "source": [ + "## Model" + ] + }, + { + "cell_type": "markdown", + "id": "2efabd94-e17c-4f16-bfa0-7ff87d297048", + "metadata": {}, + "source": [ + "### Get contacts in a list" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "e523907a-d34e-421d-a397-63b72880f128", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "def get_contacts_list(\n", + " api_key,\n", + " list_id,\n", + " limit=100,\n", + " endpoint=\"contacts\"\n", + "):\n", + " # Init\n", + " data = []\n", + " url = f\"https://api.brevo.com/v3/contacts/lists/{list_id}/contacts\"\n", + " headers = {\n", + " \"accept\": \"application/json\",\n", + " \"api-key\": api_key\n", + " }\n", + " offset = 0\n", + " while True:\n", + " params = {\n", + " \"limit\": limit,\n", + " \"offset\": offset\n", + " }\n", + " res = requests.get(url, headers=headers, params=params)\n", + " if res.status_code == 200:\n", + " result = res.json().get(endpoint)\n", + " data.extend(result)\n", + " else:\n", + " break\n", + " if len(result) == 0 or len(result) < limit:\n", + " break\n", + " else:\n", + " offset += limit\n", + " return data\n", + "\n", + "data = get_contacts_list(api_key, list_id)\n", + "data[0]" + ] + }, + { + "cell_type": "markdown", + "id": "lonely-pacific", + "metadata": { + "execution": { + "iopub.execute_input": "2021-07-02T23:32:10.789097Z", + "iopub.status.busy": "2021-07-02T23:32:10.788829Z", + "iopub.status.idle": "2021-07-02T23:32:10.796900Z", + "shell.execute_reply": "2021-07-02T23:32:10.796358Z", + "shell.execute_reply.started": "2021-07-02T23:32:10.789033Z" + }, + "papermill": {}, + "tags": [] + }, + "source": [ + "## Output" + ] + }, + { + "cell_type": "markdown", + "id": "ef2a8116-b01c-4041-8a6c-4d9d57578e53", + "metadata": {}, + "source": [ + "### Display results" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "35c1a464-d4e5-44df-bcbb-bd62e1f01187", + "metadata": { + "tags": [] + }, + "outputs": [], + "source": [ + "df = pd.DataFrame(data)\n", + "print(\"Rows:\", len(df))\n", + "df" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "fba4876d-d51c-47eb-bb0e-ba9e876ef115", + "metadata": {}, + "outputs": [], + "source": [] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.9.6" + }, + "naas": { + "notebook_id": "dd7e259333a94870bff986f6e4f3d3e1875f6fd02fbe6c6fccacd81d7fbc1336", + "notebook_path": "Sendinblue/Sendinblue_Get_no_of_undelivered_emails.ipynb" + }, + "papermill": { + "default_parameters": {}, + "environment_variables": {}, + "parameters": {}, + "version": "2.3.3" + }, + "widgets": { + "application/vnd.jupyter.widget-state+json": { + "state": {}, + "version_major": 2, + "version_minor": 0 + } + } + }, + "nbformat": 4, + "nbformat_minor": 5 +}