{"id":20949,"library":"asknews","title":"AskNews Python SDK","description":"Python SDK for AskNews, providing access to news aggregation and analysis APIs. Current version: 0.13.40. Release cadence: frequent (multiple per month).","status":"active","version":"0.13.40","language":"python","source_language":"en","source_url":"https://github.com/AskNews/asknews-python","tags":["news","api","sdk"],"install":[{"cmd":"pip install asknews","lang":"bash","label":"PyPI install"}],"dependencies":[{"reason":"HTTP client used for API requests","package":"httpx","optional":false},{"reason":"data validation and settings management","package":"pydantic","optional":false}],"imports":[{"note":"old package name","wrong":"from asknews_sdk import AskNews","symbol":"AskNews","correct":"from asknews import AskNews"},{"note":"","wrong":"","symbol":"NewsQuery","correct":"from asknews import NewsQuery"}],"quickstart":{"code":"import os\nfrom asknews import AskNews\n\nclient = AskNews(\n    api_key=os.environ.get('ASKNEWS_API_KEY', ''),\n    user_id=os.environ.get('ASKNEWS_USER_ID', '')\n)\n\nnews = client.news.search_news(query='AI', return_type='articles')\nprint(news)\n","lang":"python","description":"Initialize client with environment variables and fetch news articles."},"warnings":[{"fix":"Uninstall old package (pip uninstall asknews-sdk) and install asknews (pip install asknews). Update imports from asknews_sdk to asknews.","message":"In v0.13.0, the SDK migrated from 'asknews_sdk' to 'asknews' package. Imports and API structure changed.","severity":"breaking","affected_versions":"<0.13.0"},{"fix":"Set both environment variables: ASKNEWS_API_KEY and ASKNEWS_USER_ID.","message":"The API key and user ID must be provided together. Missing either will cause authentication failure.","severity":"gotcha","affected_versions":"all"},{"fix":"Check the API docs for the correct return_type value for your query.","message":"The search_news method's 'return_type' parameter defaults to 'articles', but some endpoints expect 'story' or 'alert'. Using wrong type may return empty results.","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-04-27T00:00:00.000Z","next_check":"2026-07-26T00:00:00.000Z","problems":[{"fix":"Uninstall the old package (pip uninstall asknews-sdk) and install the new one (pip install asknews). Then use 'from asknews import AskNews'.","cause":"Old import path from pre-0.13.0 versions.","error":"ImportError: cannot import name 'AskNews' from 'asknews_sdk'"},{"fix":"Set the environment variables ASKNEWS_API_KEY and ASKNEWS_USER_ID, or pass them directly to AskNews(api_key='...', user_id='...').","cause":"Missing or incorrect credentials.","error":"asknews.exceptions.AuthenticationError: Invalid API key or user ID"},{"fix":"Use 'language' instead of 'lang'. Check the method signature.","cause":"Parameter name changed in a recent version.","error":"TypeError: search_news() got an unexpected keyword argument 'lang'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}