Skip to content

Instantly share code, notes, and snippets.

@CVxTz
Created March 1, 2020 11:43
Show Gist options
  • Save CVxTz/2c01dc9b021e2c87f037414448ffab42 to your computer and use it in GitHub Desktop.
Save CVxTz/2c01dc9b021e2c87f037414448ffab42 to your computer and use it in GitHub Desktop.
query unsplash
# 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