-
Notifications
You must be signed in to change notification settings - Fork 454
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f309c6e
commit 3da43b0
Showing
6 changed files
with
1,697 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": [ | ||
"<img width=\"8%\" alt=\"Sendinblue.png\" src=\"https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcSmjQ8zCxxUElPg8Hr78w-njQnCghdqfAg3qRTHb7QXDQ&s\" style=\"border-radius: 15%\">" | ||
] | ||
}, | ||
{ | ||
"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 | ||
} |
Oops, something went wrong.