<jupyter_start><jupyter_text>URL`http://127.0.0.1:5000/`![](https://qph.fs.quoracdn.net/main-qimg-1df2405abe09c3bac85c7491686e3073)- SCHEME: `Protocol`- PATH: `endpoint`- QUERY STRING: `query params`<jupyter_code>@app.route("/")
def root():
  return {"Hello": "World!"}
import requests
url = 'https://api.wheretheiss.at/v1/satellites'
response = requests.get(url)
type(response)
response.status_code
info = response.json()
info
type(info)
info[0]['id']
# PAra poder buscar la posición
url_iss_position = "https://api.wheretheiss.at/v1/satellites/25544"
response = requests.get(url_iss_position)
response.status_code
response.json()
response.headers
import time
positions = []
for i in range(10):
  print(i)
  response = requests.get(url_iss_position)
  data = response.json()
  positions.append(data)
  time.sleep(1)
positions[0]
import pandas as pd
pd.DataFrame(positions)<jupyter_output><empty_output><jupyter_text>PymongoPasos para local<jupyter_code>#!pip install dnspython
#!pip install pymongo
from pymongo import MongoClient
# Instanciamos la clase MongoClient al objeto client
client = MongoClient()
client
# utilizamos client.database
client.CusterTheBridge
# database.collection
# client.database.collection
db = client.CusterTheBridge
db.sample.airbnb<jupyter_output><empty_output><jupyter_text>> Pasos a realizar en MongoDB Atlas<jupyter_code># Definir una función para recoger las variables o credenciales
def get_creds(line=None):
    keys = []
    for l in line:
        keys.append(l.split("=")[1].splitlines(False)[0])
    return keys
mongo_creds = open("/content/creds.txt", "r")
lines = mongo_creds.readlines()
# user = get_creds(lines)[0]
# password = get_creds(lines)[1]
# dbName = "CusterTheBridge"
# creds = open("/content/creds.txt", "r")
# for line in creds:
#   pieces = line.split("=")
#   user = pieces[0]
#   password = pieces[1]
user = ""
password = ""
dbName = ""
# Conexión con el MongoCluster
client = MongoClient(f"mongodb://{user}:{password}@endpoint")
import pymongo
uri = "mongodb://endpoint"
client = pymongo.MongoClient(uri)
db = client.inventory
db
items = {
    "Type" : "Laptop",
    "ItemNumber" : "1234EXD"
}
# creamos una collection de objetos
collection = db.items
collection.insert_one(items)<jupyter_output><empty_output>
StarcoderdataJupyterStructuredCleanDedup