Coder Social home page Coder Social logo

Consumo de APIS about public-apis HOT 3 CLOSED

MarZamora29 avatar MarZamora29 commented on June 6, 2024
Consumo de APIS

from public-apis.

Comments (3)

MarZamora29 avatar MarZamora29 commented on June 6, 2024

import requests

def obtener_direccion_falsa():
url = "https://fakerapi.it/api/v1/addresses?_quantity=1"
respuesta = requests.get(url)
datos = respuesta.json()
direccion = datos['data'][0]
return direccion

direccion_falsa = obtener_direccion_falsa()
print("Dirección falsa generada:")
print("Calle:", direccion_falsa['address'])
print("Ciudad:", direccion_falsa['city'])
print("Código postal:", direccion_falsa['zip'])
print("País:", direccion_falsa['country'])

from public-apis.

MarZamora29 avatar MarZamora29 commented on June 6, 2024

import requests

url = "https://fakerapi.it/api/v1/persons"
params = {
"_quantity": 1,
"_gender": "male",
"_birthday_start": "2005-01-01"
}

response = requests.get(url, params=params)

if response.status_code == 200:
data = response.json()
person = data['data'][0]
print("Información de la persona:")
print("Nombre:", person['firstname'], person['lastname'])
print("Género:", person['gender'])
print("Fecha de nacimiento:", person['birthday'])
print("Dirección:", person['address'])
print("Email:", person['email'])
print("Teléfono:", person['phone_number'])
else:
print("Error al obtener los datos de la API.")

from public-apis.

MarZamora29 avatar MarZamora29 commented on June 6, 2024

import requests

def obtener_lugar():
url = "https://fakerapi.it/api/v1/places?_quantity=1"
response = requests.get(url)
data = response.json()
lugar = data['data'][0]
return lugar

if name == "main":
lugar = obtener_lugar()
print("Lugar generado aleatoriamente:")
print("Nombre:", lugar['name'])
print("Dirección:", lugar['address'])
print("Ciudad:", lugar['city'])
print("Estado:", lugar['state'])
print("País:", lugar['country'])
print("Código postal:", lugar['zipcode'])

from public-apis.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.