An easy-to-use and async-ready Python wrapper for the API-Ninjas APIs.
- Pythonic and modern API
- Asynchronous using
async
andawait
- Fully type-hinted
- Easy to use with an object oriented design
Python 3.9 or higher is required
To install the latest stable version, use
pip install -U apininjas.py
To install the development version (may be unstable), use
pip install -U git+https://github.com/codeofandrin/apininjas.py
import asyncio
from apininjas import Client
async def main():
client = Client("api_key")
stock = await client.fetch_stock("AAPL")
print(f"{stock.name} is trading at ${stock.price}")
await client.close()
if __name__ == "__main__":
asyncio.run(main())
Or use the context manager, which automatically cleans up.
import asyncio
from apininjas import Client
async def main():
async with Client("api_key") as client:
stock = await client.fetch_stock("AAPL")
print(f"{stock.name} is trading at ${stock.price}")
if __name__ == "__main__":
asyncio.run(main())