{"id":21727,"library":"pyalex","title":"Pyalex","description":"Pyalex is a Python wrapper for the OpenAlex API, providing convenient access to scholarly data (authors, works, institutions, etc.) from the OpenAlex database. Current version is 0.21, requiring Python >=3.8. It follows the OpenAlex API versioning and is actively maintained.","status":"active","version":"0.21","language":"python","source_language":"en","source_url":"https://github.com/J535D165/pyalex","tags":["openalex","scholarly-data","api-wrapper","bibliometrics","academic"],"install":[{"cmd":"pip install pyalex","lang":"bash","label":"Latest stable release"},{"cmd":"pip install git+https://github.com/J535D165/pyalex.git","lang":"bash","label":"Latest development version"}],"dependencies":[{"reason":"HTTP client for API calls","package":"requests","optional":false},{"reason":"Retry mechanism for rate limits","package":"backoff","optional":false},{"reason":"Progress bars for iterators","package":"tqdm","optional":true}],"imports":[{"note":"Works is a top-level class, not a submodule. The incorrect import will raise ModuleNotFoundError.","wrong":"from pyalex.Works import Works","symbol":"Works","correct":"from pyalex import Works"},{"note":"Common mistake: trying to import as a module instead of a class.","wrong":"import pyalex.Authors","symbol":"Authors","correct":"from pyalex import Authors"},{"note":"Config is used to set API key and email, e.g., Config.email = 'your@email.com'.","wrong":"","symbol":"Config","correct":"from pyalex import Config"}],"quickstart":{"code":"from pyalex import Works, Config\nimport os\n\n# Configure email (optional but recommended for polite API usage)\nConfig.email = os.environ.get('OPENALEX_EMAIL', 'you@example.com')\n\n# Fetch a work by OpenAlex ID\nwork = Works()['W2741809807']\nprint(work['title'])\n\n# Search for works\nfor work in Works().search('machine learning').get():\n    print(work['title'])\n    break","lang":"python","description":"Basic usage: fetch a single work by ID and perform a search query."},"warnings":[{"fix":"Add `.get()` to the end of your query chain, e.g., `Works().search('AI').get()`.","message":"In pyalex 0.19 and earlier, the `Works()` call without arguments returned an iterator over all works. In 0.20+, you must explicitly call `.get()` to execute the query. Direct iteration over `Works()` without `.get()` now raises a TypeError.","severity":"breaking","affected_versions":">=0.20"},{"fix":"Set `Config.email = 'your@email.com'` at the start of your script to get a higher rate limit and polite usage.","message":"The OpenAlex API has a rate limit of 10 requests per second for unauthenticated requests and 100 per second with an email header. Pyalex does not automatically add email; you must set `Config.email`. Without it, you may get 429 errors under heavy usage.","severity":"gotcha","affected_versions":"all"},{"fix":"Replace `from pyalex import works; works()...` with `from pyalex import Works; Works()...`.","message":"The `works()` function (lowercase) is deprecated in favor of `Works` class (uppercase). The old function may be removed in a future version.","severity":"deprecated","affected_versions":">=0.17"},{"fix":"For combined filters, use `.filter()` with a single dict, e.g., `Works().filter({'year': 2020, 'is_oa': True}).get()`.","message":"When using `.search()` with multiple filters, ensure you chain them correctly. Filters like `filter={'year': 2020}` and `search='term'` are applied as separate calls, not combined in one filter dict.","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":"Use `from pyalex import Works` instead of `from pyalex.Works import Works`.","cause":"Incorrect import path; Works is a class, not a submodule.","error":"ModuleNotFoundError: No module named 'pyalex.Works'"},{"fix":"Do not instantiate Config. Use `Config.email = '...'` directly.","cause":"Trying to call Config() as a function; Config is a class used to set attributes directly.","error":"TypeError: 'Config' object is not callable"},{"fix":"Call `.get()` on the query object before iterating, e.g., `for work in Works().get():`.","cause":"In pyalex 0.20+, Works() is no longer iterable without calling .get(). This is a common error when upgrading from older versions.","error":"AttributeError: 'Works' object has no attribute '__iter__'"}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}