Skip to content

weatherapi.APIsApi().time_zone() Returning None #8

@OkhtayMp

Description

@OkhtayMp

Description

I am experiencing an issue when using the weatherapi Python module to get time zone data. The same query returns the correct data when used with curl, but the Python code results in all values being None. Below is the detailed information.

Problem

Python code

docs https://github.com/weatherapicom/python/blob/main/docs/APIsApi.md#time_zone
code:

from __future__ import print_function
import weatherapi, os
from weatherapi.rest import ApiException
from pprint import pprint

# Configure API key authorization
configuration = weatherapi.Configuration()
configuration.api_key['key'] = '842d02b59aa14719b54203909241012'

api_instance = weatherapi.APIsApi(weatherapi.ApiClient(configuration))
q = '2.182.58.74'  

try:
    api_response = api_instance.time_zone(q)
    pprint(api_response)
except ApiException as e:
    print("Exception when calling APIsApi->time_zone: %s\n" % e)

Output:

{
    'country': None,
    'lat': None,
    'localtime': None,
    'localtime_epoch': None,
    'lon': None,
    'name': None,
    'region': None,
    'tz_id': None
}

CURL command

command:

curl -X GET "http://api.weatherapi.com/v1/timezone.json?key=842d02b59aa14719b54203909241012&q=2.182.58.74"

Output:

{
    "location": {
        "name": "Tabriz",
        "region": "East Azarbaijan",
        "country": "Iran",
        "lat": 38.075,
        "lon": 46.247,
        "tz_id": "Asia/Tehran",
        "localtime_epoch": 1733866577,
        "localtime": "2024-12-11 01:06"
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions