Skip to main content

API to thispersondoesnotexist.com

Project description

ThisPersonDoesNotExistAPI

Unofficial "API" for the ThisPersonDoesNotExist website.

What is ThisPersonDoesNotExist?

A page that returns a JPEG picture of a person that does not exist, because it has been generated using an AI. When opening the webpage, a image is returned directly, and refreshing the page will return a new image (although they can be repeated because the repository is limited and images are not generated on real time).

Some articles about it:

Why creating/using an "API"?

Why not? Use your imagination!

Requirements

  • Python 3.6
  • requests library
  • free time

Usage

Get a person using function

from thispersondoesnotexist import get_online_person
picture = await get_online_person()  # bytes representation of the image

# Save to a file
from thispersondoesnotexist import save_picture
await save_picture(picture, "a_beautiful_person.jpeg")
# If no filename is provided, one will be generated using the checksum of the picture
await save_picture(picture)

Get a person using class

from thispersondoesnotexist import Person
# Initialize with True to automatically get a person from the webpage
person = Person(fetch_online=True)

# Save to a file
await person.save("a_beautiful_person.jpeg")
# If no filename is provided, one will be generated using the checksum of the picture
await person.save()

Generate checksums

This can be useful if you want to create a scraper of fictional persons. You would be calling the methods to get random pictures, and to avoid repeating them, you can use their checksum - or just save with the auto-generated filename.

from thispersondoesnotexist import get_online_person, get_checksum_from_picture, Person

# Using object
person = Person(fetch_online=True)
checksum = person.get_checksum("md5")

# Using function
picture = await get_online_person()
checksum2 = get_checksum_from_picture(picture)  # Method is optional, defaults to "md5"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for thispersondoesnotexist, version 1.0.0
Filename, size File type Python version Upload date Hashes
Filename, size thispersondoesnotexist-1.0.0.tar.gz (3.3 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page