GET request to TheDogApi gives a 443 code

Hello Aden,

Hoping you can help me out Aden, I’ve been trying to use your api for a dog app I was creating but having a hard time accessing the dog api. I’ve fixed flaws in my code but still can’t get access. Heres the response I’m getting in the terminal,
DEBUG: Starting new HTTPS connection (1): api.thedogapi.com:443
DEBUG: https://api.thedogapi.com:443 “GET /v1/breeds/search?/q:akita/quote?token=(shows my api key number here) HTTP/1.1” 200 2

Thanks for your time

The “443” in that image is referring to the port number it’s connecting with: HTTPS/443.

The result you’re getting is at the end of the second line: 200 (OK)

So the API is working, something else is going wrong in your code after the fact. Would you mind sharing what you’re trying to do? I might be able to help out :slight_smile:

def lookup(param_value):
# Contact API
try:
api_key = os.environ.get(“x-api-key”)
response = requests.get(f"https://api.TheDogApi.com/v1/breeds/search?/q:{urllib.parse.quote_plus(str(param_value))}/quote?token={api_key}")
response.raise_for_status()
except requests.RequestException:
return None

# Parse response
try:
    quote = response.json()
    return {
        "name": quote["name"],
        "origin": quote["origin"],
        "temperament": quote["temperament"]
    }
except (KeyError, TypeError, ValueError):
    return None

I’m using HTML and flask to build this app for my final project

try:
quote = response.json()
return {
“name”: quote[“name”],
“origin”: quote[“origin”],
“temperament”: quote[“temperament”]
}
except (KeyError, TypeError, ValueError):
return None

Hi @Ramses,

Looks like the url you’re using is slightly off.

should read: /v1/breeds/search?q=akita&api_key=your-api-key-here

e.g. https://api.thedogapi.com/v1/breeds/search?q=akita&api_key=YOUR-KEY

Fixes:

  • In a URL only the first query parameter should begin “?” - the rest should be separated by a “&”
  • the query term doesn’t need to be wrapped in quotes
  • token should be api_key

Let us know if you’re still having issues though,

All the best, Aden