Pacifica SDK
Pacifica SDK is a Python library for interacting with the Pacifica.fi exchange API and WebSocket.
The SDK supports asynchronous requests, convenient order management, account operations, market data retrieval, and real-time data streams.
Installation
pip install pacifica-sdk
Dependencies:
Quick Start
Get Market Information
import asyncio
from pacifica_sdk.async_.info import Info
async def main():
info = Info()
markets = await info.get_market_info()
for market in markets:
print(market.symbol, market.max_leverage)
await info.close()
asyncio.run(main())
Create a Limit Order
import asyncio
from pacifica_sdk.async_.exchange import Exchange
from pacifica_sdk.models.requests import CreateLimitOrder, Side, TIF
PRIVATE_KEY = "YOUR_PRIVATE_KEY"
async def main():
exchange = Exchange(private_key=PRIVATE_KEY)
order = CreateLimitOrder(
symbol="BTCUSDT",
price="30000",
amount="0.01",
side=Side.BID,
tif=TIF.GTC,
)
response = await exchange.create_order(order)
print("Order ID:", response.data.order_id)
await exchange.close()
asyncio.run(main())
Subscribe to Price Stream via WebSocket
import asyncio
from pacifica_sdk.async_.websocket_manager import WebsocketManager
from pacifica_sdk.models.ws_subscribe import WSPricesSubscribe
async def on_prices_update(data):
print("Prices update:", data)
async def main():
ws_manager = WebsocketManager()
params = WSPricesSubscribe()
await ws_manager.subscribe(params, on_prices_update)
await asyncio.sleep(60)
await ws_manager.close()
asyncio.run(main())
Error Handling
The SDK raises custom exceptions:
ApiError— for API errors (4xx)ServerError— for server errors (5xx)
from pacifica_sdk.utils.error import ApiError, ServerError
try:
# Your code here
...
except ApiError as e:
print("API error:", e)
except ServerError as e:
print("Server error:", e)
Package Structure
pacifica_sdk.async_— asynchronous clients (API, Exchange, Info, WebSocket)pacifica_sdk.models— Pydantic models for requests, responses, and streamspacifica_sdk.utils— utilities, error handling, message signingpacifica_sdk.enums— enums for statuses, order types, etc.pacifica_sdk.constants— constants (URLs, etc.)
Documentation
Roadmap / Upcoming Features
The following features are planned for future releases:
-
Trading operations via WebSocket:
Place, modify, and cancel orders in real time using the WebSocket API. -
Comprehensive docstrings:
All public classes and functions will include detailed docstrings for better developer experience and IDE support. -
More usage examples:
The documentation and repository will include more practical code samples for common SDK use cases. -
Price and order size rounding utilities:
Helper functions for correct rounding of prices and order sizes according to market requirements. -
Synchronous client:
(Planned) Support for synchronous (non-async) usage for simpler integration in legacy projects. -
Extensive test coverage:
More unit and integration tests to ensure reliability and stability. -
Type hints and static analysis improvements:
Even stricter type checking and mypy compatibility. -
Logging in all modules:
Consistent and configurable logging will be added across all SDK modules for better debugging and monitoring.
If you have feature requests or suggestions, feel free to open an issue or contact us!
License
MIT License
Contacts
- Telegram: @hedgehog
Pull requests and bug reports are welcome!
Release files for pacifica-sdk 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| pacifica_sdk-0.1.0.tar.gz | 16.3 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pacifica_sdk-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 35.7 kB
Release files / pacifica_sdk-0.1.0.tar.gz
| Download URL | pacifica_sdk-0.1.0.tar.gz |
|---|---|
| Size | 16.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
ad705c0826359eff2486f03ca22ff3c9f0cb4e7d437b6ccbf4e0d405f066c41c
|
|
BLAKE2b-256 checksum How to use checksums |
0c17369f3adc8b3a343ea84ab6e9f2bbbe40069c39f0dc8169cab865de9bedfc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|
Release files / pacifica_sdk-0.1.0-py3-none-any.whl
| Download URL | pacifica_sdk-0.1.0-py3-none-any.whl |
|---|---|
| Size | 19.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
c46c733327af5d947a16dbda9da5bfb0b8077550c6715a4478cca1cfd66071aa
|
|
BLAKE2b-256 checksum How to use checksums |
c257eba48c7739c10cd57b90a85d000d537119e1a0ebd6e0529ee76e976726ec
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.4
|