Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
6 changes: 3 additions & 3 deletions Module_1/Lab_13_APIs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ In order to get started, we'd like you to create an access token in your [Github

![Github create personal token](./images/github-create-token.png)

A personal access token is a secret password to allow you or your app to make remote requests to the Github API. It is the same [oAuth](https://oauth.net/) technology as the Twitter developer access token discussed in the lesson but in Github you don't need to wait for the approval and your token will be available immediately.
A personal access token is a secret password to allow you or your app to make remote requests to the Github API. It is the same [oAuth](https://oauth.net/) technology as the Twitter developer access token discussed in the lesson but in Github you don't need to wait for the appèè``roval and your token will be available immediately.

:exclamation: Make sure you save the token on your computer because this is the only time you will see the token string. If for any reason you lost your token, simply come back to Github and re-authorize yourself a new token.

Expand All @@ -25,8 +25,8 @@ A personal access token is a secret password to allow you or your app to make re
After generating the token, you can test it with `curl` in the Terminal. Assuming your Git username is `johndoe` and token is `d10ev1shpm10x5qox9ckw1k9b792p9rq0ogplpn5cyo55`, you can make the curl command in the following way:

```bash
$ curl -u johndoe:d10ev1shpm10x5qox9ckw1k9b792p9rq0ogplpn5cyo55 https://api.github.com/user`
```
$ curl -u johndoe:d10ev1shpm10x5qox9ckw1k9b792p9rq0ogplpn5cyo55 https://api.github.com/user```
`````

If your token is valid, you will see a JSON response that looks like:

Expand Down
311 changes: 311 additions & 0 deletions Module_1/Lab_13_APIs/lab13 API.ipynb

Large diffs are not rendered by default.

34 changes: 34 additions & 0 deletions Module_1/Lab_13_APIs/output.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"login": "benstL",
"id": 48924556,
"node_id": "MDQ6VXNlcjQ4OTI0NTU2",
"avatar_url": "https://avatars.githubusercontent.com/u/48924556?v=4",
"gravatar_id": "",
"url": "https://api.github.com/users/benstL",
"html_url": "https://github.com/benstL",
"followers_url": "https://api.github.com/users/benstL/followers",
"following_url": "https://api.github.com/users/benstL/following{/other_user}",
"gists_url": "https://api.github.com/users/benstL/gists{/gist_id}",
"starred_url": "https://api.github.com/users/benstL/starred{/owner}{/repo}",
"subscriptions_url": "https://api.github.com/users/benstL/subscriptions",
"organizations_url": "https://api.github.com/users/benstL/orgs",
"repos_url": "https://api.github.com/users/benstL/repos",
"events_url": "https://api.github.com/users/benstL/events{/privacy}",
"received_events_url": "https://api.github.com/users/benstL/received_events",
"type": "User",
"site_admin": false,
"name": "Benoistl",
"company": null,
"blog": "",
"location": null,
"email": null,
"hireable": null,
"bio": null,
"twitter_username": null,
"public_repos": 9,
"public_gists": 0,
"followers": 1,
"following": 0,
"created_at": "2019-03-25T17:43:51Z",
"updated_at": "2023-07-10T07:36:30Z"
}
164 changes: 164 additions & 0 deletions Module_1/Lab_15_Stack-API/lab_15_Stack_API_exercise.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# StackAPI\n",
"\n",
"#### Import the necessary libraries here:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"# your code here\n",
"from stackapi import StackAPI"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Question 1: Find the questions and answers of last month."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'backoff': 0,\n",
" 'has_more': False,\n",
" 'page': 1,\n",
" 'quota_max': 300,\n",
" 'quota_remaining': 141,\n",
" 'total': 0,\n",
" 'items': []}"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# your code here\n",
"from stackapi import StackAPI\n",
"SITE = StackAPI('stackoverflow')\n",
"questions = SITE.fetch('questions', fromdate=1686486964, todate=1686486964, min=20, tagged='python', sort='votes')\n",
"questions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Question 2: Find the most voted question today with at least a score of 5 and tagged with 'python'. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'backoff': 0,\n",
" 'has_more': False,\n",
" 'page': 1,\n",
" 'quota_max': 300,\n",
" 'quota_remaining': 130,\n",
" 'total': 0,\n",
" 'items': []}"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# your code here\n",
"\n",
"from stackapi import StackAPI\n",
"SITE = StackAPI('stackoverflow')\n",
"questions = SITE.fetch('questions', fromdate=1689079147, todate=1689079147, min=20, tagged='python', sort='votes')\n",
"questions"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"#### Question 3: Find the answers with id 6784 and 6473."
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'backoff': 0,\n",
" 'has_more': False,\n",
" 'page': 1,\n",
" 'quota_max': 300,\n",
" 'quota_remaining': 121,\n",
" 'total': 0,\n",
" 'items': []}"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# your code here\n",
"\n",
"from stackapi import StackAPI\n",
"SITE = StackAPI('stackoverflow')\n",
"answers = SITE.fetch('answers', fromdate=1689079147, todate=1689079147, min=20, tagged='python', sort='votes', id=[6784, 6474])\n",
"answers"
]
}
],
"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.11.4"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Loading