How to automate your Flickr searches?
First: does the API key still work?
This query uses the public API key "3aac009af063175e4bb3623f9d3c557b" from Flickr. In our previous blog post, we already indicated that this API key probably cannot be used indefinitely. This is correct, because when you run the above query you will see the error message below. In this error message, you will see the error code 100, followed by the message "Invalid API Key (Key not found)". Thus, Flickr's public API key no longer works.
Expiration of an API key
The API key that we used on April 23, 2020, unfortunately no longer works today. If you use public API keys, you will often find that an API key no longer works at some point. The usability can stop in different ways: for example, a key may no longer be valid after a x number of uses, or for example because the usability stops after a certain period of time.
Twitter user @OsintSupport (check out his awesome Chrome extensions!) has informed us that the public API key is replaced every 8 hours with a new API key. This means that the key is valid for about 8 hours. Moreover, the use of the API key would not be blocked on the basis of repeated use by a single user: the API key can therefore be used for many thousands of requests from the same IP address. And that makes the use of the API request interesting to automate.
Automate your searches
Get started with Python
Step 1: download and installation of Python
Step 2: Download Notepad++
Step 3: Download the Request-library
The so-called Requests library that allows you to send HTTP requests is an example of a code that is not included by default in Python. You must therefore install this library before you can use it. This can be done as follows.
Pip install requests
python -m pip install --upgrade pip
Step 4: Import the Requests-library
Step 5: Define the URL
However, because the API key of this query turned out to be no longer valid, we have a new query below that will make the request work again. If you want to do this yourself, you will have to use Flickr's public API key again or obtain a private key yourself.
url = 'https://www.flickr.com/services/rest/?method=flickr.people.findByEmail&api_key=b51834379b8a3b68db81bf2ea953a03e&find_email=davidjones%40yahoo.com&format=rest'
Step 6: Run the request and save the response in a variable
#request uitvoeren en uitkomst in een variabele opslaan
response = requests.get(url)
Step 7: Print the result
#het resultaat printen (statuscode)
We use the following code to print the content of the web page in text form.
#het resultaat printen (tekst)
Step 8: Run the Python-script
- Open the Windows Command Prompt;
- Typ in "cd Desktop"*;
- Typ in "python Flickr.py".
*: in our example, the Python script is stored on the desktop. With the command "cd" (change directory) we opened the folder "Desktop". If your script is stored in a different folder, first navigate to this folder.