Skip to main content

Python3 Bybit HTTP/WebSocket API Connector

Project description

pybit

All Contributors

Build Status Build Status contributions welcome

Official Python3 API connector for Bybit's HTTP and WebSockets APIs.

Table of Contents

About

Put simply, pybit (Python + Bybit) is the official lightweight one-stop-shop module for the Bybit HTTP and WebSocket APIs. Originally created by Verata Veritatis, it's now maintained by Bybit employees – however, you're still welcome to contribute!

It was designed with the following vision in mind:

I was personally never a fan of auto-generated connectors that used a mosh-pit of various modules you didn't want (sorry, bravado) and wanted to build my own Python3-dedicated connector with very little external resources. The goal of the connector is to provide traders and developers with an easy-to-use high-performing module that has an active issue and discussion board leading to consistent improvements.

Development

pybit is being actively developed, and new Bybit API changes should arrive on pybit very quickly. pybit uses requests and websocket-client for its methods, alongside other built-in modules. Anyone is welcome to branch/fork the repository and add their own upgrades. If you think you've made substantial improvements to the module, submit a pull request and we'll gladly take a look.

Installation

pybit requires Python 3.10 or higher. The module can be installed manually or via PyPI with pip:

pip install pybit

Usage

You can retrieve a specific market like so:

from pybit.unified_trading import HTTP

Create an HTTP session and connect via WebSocket for Inverse on mainnet:

session = HTTP(
    testnet=False,
    api_key="...",
    api_secret="...",
)

Information can be sent to, or retrieved from, the Bybit APIs:

# Get the orderbook of the USDT Perpetual, BTCUSDT
session.get_orderbook(category="linear", symbol="BTCUSDT")

# Create five long USDC Options orders.
# (Currently, only USDC Options support sending orders in bulk.)
payload = {"category": "option"}
orders = [{
  "symbol": "BTC-30JUN23-20000-C",
  "side": "Buy",
  "orderType": "Limit",
  "qty": "0.1",
  "price": i,
} for i in [15000, 15500, 16000, 16500, 16600]]

payload["request"] = orders
# Submit the orders in bulk.
session.place_batch_order(payload)

P2P HTTP methods are available from the same unified trading session:

session.get_account_information()
session.get_ads_list()

Check out the example python files or the list of endpoints below for more information on available endpoints and methods. Usage examples on the HTTP methods can be found in the examples folder.

Contact

Reach out for support on your chosen platform:

Contributors

Thanks goes to these wonderful people (emoji key):


dextertd

💻 📖

ervuks

💻 📖

verata-veritatis

💻 📖

APF20

💻

Cameron Harder-Hutton

💻

Tom Rumpf

💻

OnJohn

💻

Todd Conley

🤔

Kolya

💻 📖

This project follows the all-contributors specification. Contributions of any kind welcome!

Project details


Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pybit-5.16.1.tar.gz (64.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pybit-5.16.1-py2.py3-none-any.whl (58.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file pybit-5.16.1.tar.gz.

File metadata

  • Download URL: pybit-5.16.1.tar.gz
  • Upload date:
  • Size: 64.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pybit-5.16.1.tar.gz
Algorithm Hash digest
SHA256 732225ee5d59f9b3df9b14fa5d828b95486959b10f41e26f73735bbfe3b73773
MD5 f2e677615e3de582c3fa103a721cc219
BLAKE2b-256 2e39fbb1222c10bceb750cafc2856faa6918e8653ee33f8f12f04558ae8d1fbe

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybit-5.16.1.tar.gz:

Publisher: publish.yml on bybit-exchange/pybit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file pybit-5.16.1-py2.py3-none-any.whl.

File metadata

  • Download URL: pybit-5.16.1-py2.py3-none-any.whl
  • Upload date:
  • Size: 58.7 kB
  • Tags: Python 2, Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for pybit-5.16.1-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 74927ebbe160e97e6f203c62075604a816d57c3da37171cf5a43e82b60539911
MD5 66b2408a34230eda9dc2c4f32e5c4d9d
BLAKE2b-256 7bfbfd739f1fcdb3a2ab57e060259430ae530555265f6b0b13e7b9c0aa682589

See more details on using hashes here.

Provenance

The following attestation bundles were made for pybit-5.16.1-py2.py3-none-any.whl:

Publisher: publish.yml on bybit-exchange/pybit

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page