Welcome to DeclarativeX 🚀¶
Introduction¶
Hey there! Welcome to the official documentation of DeclarativeX. If you're tired of writing boilerplate code for HTTP clients and want a more declarative approach, you're in the right place. DeclarativeX is designed to make your life easier, letting you focus on what really matters—your application logic.
Installation¶
Getting started with DeclarativeX is a breeze. Just run the following command:
pip install declarativex
And boom! You're good to go.
Available extras¶
DeclarativeX comes with a few extras that you can install separately. Here's a list of available extras:
http2
- HTTP/2 supportgraphql
- GraphQL supportbrotli
- Brotli compression support
To install an extra, just add it to the end of the command:
pip install declarativex[http2,graphql,brotli]
pip install declarativex[http2]
Quick Start Guide¶
Ready to dive in? Here's a quick example to get you started:
from declarativex import BaseClient, http
@http("GET", "/users/{user_id}", "https://example.com")
def get_user(user_id: int) -> dict:
...
response = get_user(user_id=1)
print(response)
import asyncio
from declarativex import BaseClient, http
@http("GET", "/users/{user_id}", "https://example.com")
async def get_user(user_id: int) -> dict:
...
response = asyncio.run(get_user(user_id=1))
print(response)
You should see the following output:
{
"id": 1,
"name": "John Doe"
}
Async
DeclarativeX supports both synchronous and asynchronous HTTP requests. Just define your function as async
and
you're good to go.
See? No fuss, just clean and straightforward code.
Why DeclarativeX?¶
- Less Boilerplate: No more repetitive code for HTTP methods.
- Type-Safe: Built with type annotations for better code quality.
- Flexible: Easily extendable to fit your specific needs.
What's Next?¶
Feel free to explore the documentation to get a deeper understanding of DeclarativeX. Whether you're looking to understand the core concepts, decorators, or how to set up dependencies, we've got you covered.
Contributing¶
Love DeclarativeX and want to contribute? Awesome! Check out our Contribution Guidelines.