Created
March 1, 2020 11:43
-
-
Save CVxTz/2c01dc9b021e2c87f037414448ffab42 to your computer and use it in GitHub Desktop.
query unsplash
This file contains hidden or 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
# First install https://github.com/yakupadakli/python-unsplash | |
# Unsplash API https://unsplash.com/documentation | |
import json | |
import os | |
from unsplash.api import Api | |
from unsplash.auth import Auth | |
with open('tokens.json', 'r') as f: | |
data = json.load(f) | |
client_id = data['client_id'] | |
client_secret = data['client_secret'] | |
redirect_uri = "" | |
code = "" | |
keyword = 'beach' | |
auth = Auth(client_id, client_secret, redirect_uri, code=code) | |
api = Api(auth) | |
photos = api.search.photos(keyword, per_page=1000, page=i)['results'] | |
for photo in photos: | |
print(photo) | |
print(photo.id) | |
print(photo.urls) | |
print(photo.urls.small) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment