pymexc


Namepymexc JSON
Version 1.2.11 PyPI version JSON
download
home_pagehttps://github.com/makarworld/pymexc.git
SummaryUnofficial python library for interacting with the MEXC crypto exchange
upload_time2025-08-09 13:49:35
maintainerNone
docs_urlNone
authorabuztrade
requires_python>=3.6.0
licenseMIT
keywords mexc mexc api mexc api v1 mexc futures bypass mexc api v2 mexc api v3 mexc spot mexc futures mexc websocket mexc http mexc rest
VCS
bugtrack_url
requirements curl-cffi websocket-client wsaccel websockets protobuf python-dotenv pytest pytest-asyncio aiohttp
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![PyPI version](https://badge.fury.io/py/pymexc.svg)](https://badge.fury.io/py/pymexc)
[![License](https://img.shields.io/github/license/makarworld/pymexc.svg?label=License&logo=apache&cacheSeconds=2592000)](https://github.com/makarworld/pymexc/blob/main/LICENSE)
[![image](https://img.shields.io/pypi/pyversions/pymexc.svg)](https://pypi.org/project/pymexc/)
[![Github last commit date](https://img.shields.io/github/last-commit/makarworld/pymexc.svg?label=Updated&logo=github&cacheSeconds=600)](https://github.com/makarworld/pymexc/commits)

# pymexc

`pymexc` is an unofficial Python library for interacting with the [MEXC crypto exchange](https://www.mexc.com/). It provides a simple and intuitive API for making requests to the [MEXC API endpoints](https://mexcdevelop.github.io/apidocs/spot_v3_en/#introduction).

Base of code was taken from [pybit](https://github.com/bybit-exchange/pybit) library.

# Futures orders API

MEXC Futures API for create orders is on maintance now. **_But you can bypass it_**. See [this issue](https://github.com/makarworld/pymexc/issues/15) for more information.

# Installation

You can install pymexc using pip:

```bash
pip install pymexc
```

# Getting Started

To start working with pymexc, you must import spot or futures from the library. Each of them contains 2 classes: HTTP and WebSocket. To work with simple requests, you need to initialize the HTTP class. To work with web sockets you need to initialize the WebSocket class 

## Example

```python
from pymexc import spot, futures

api_key = "YOUR API KEY"
api_secret = "YOUR API SECRET KEY"

def handle_message(message): 
    # handle websocket message
    print(message)


# SPOT V3

# initialize HTTP client
spot_client = spot.HTTP(api_key = api_key, api_secret = api_secret)
# initialize WebSocket client
ws_spot_client = spot.WebSocket(api_key = api_key, api_secret = api_secret)

# make http request to api
print(spot_client.exchange_info())

# create websocket connection to public channel (spot@public.deals.v3.api@BTCUSDT)
# all messages will be handled by function `handle_message`
ws_spot_client.deals_stream(handle_message, "BTCUSDT")


# FUTURES V1

# initialize HTTP client
futures_client = futures.HTTP(api_key = api_key, api_secret = api_secret)
# initialize WebSocket client
ws_futures_client = futures.WebSocket(api_key = api_key, api_secret = api_secret, 
                                      # subscribe on personal information about about account
                                      # if not provided, will not be subscribed
                                      # you can subsctibe later by calling ws_futures_client.personal_stream(callback) for all info
                                      # or ws_futures_client.filter_stream(callback, params={"filters":[{"filter":"..."}]}) for specific info (https://mexcdevelop.github.io/apidocs/contract_v1_en/#filter-subscription)
                                      personal_callback = handle_message)

# make http request to api
print(futures_client.index_price("MX_USDT"))

# create websocket connection to public channel (sub.tickers)
# all messages will be handled by function `handle_message`
ws_futures_client.tickers_stream(handle_message)

# loop forever for save websocket connection 
while True: 
    ...
```

# Documentation

You can find the official documentation for the MEXC API [here](https://mexcdevelop.github.io/apidocs/spot_v3_en/#introduction).

# License

This library is licensed under the MIT License.

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/makarworld/pymexc.git",
    "name": "pymexc",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.6.0",
    "maintainer_email": null,
    "keywords": "mexc, mexc api, mexc api v1, mexc futures bypass, mexc api v2, mexc api v3, mexc spot, mexc futures, mexc websocket, mexc http, mexc rest",
    "author": "abuztrade",
    "author_email": "abuztrade.work@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7d/93/5010cdcb49a6adc0386917518025337aee1b5d4822e11b0d82c94e1d55e1/pymexc-1.2.11.tar.gz",
    "platform": null,
    "description": "[![PyPI version](https://badge.fury.io/py/pymexc.svg)](https://badge.fury.io/py/pymexc)\r\n[![License](https://img.shields.io/github/license/makarworld/pymexc.svg?label=License&logo=apache&cacheSeconds=2592000)](https://github.com/makarworld/pymexc/blob/main/LICENSE)\r\n[![image](https://img.shields.io/pypi/pyversions/pymexc.svg)](https://pypi.org/project/pymexc/)\r\n[![Github last commit date](https://img.shields.io/github/last-commit/makarworld/pymexc.svg?label=Updated&logo=github&cacheSeconds=600)](https://github.com/makarworld/pymexc/commits)\r\n\r\n# pymexc\r\n\r\n`pymexc` is an unofficial Python library for interacting with the [MEXC crypto exchange](https://www.mexc.com/). It provides a simple and intuitive API for making requests to the [MEXC API endpoints](https://mexcdevelop.github.io/apidocs/spot_v3_en/#introduction).\r\n\r\nBase of code was taken from [pybit](https://github.com/bybit-exchange/pybit) library.\r\n\r\n# Futures orders API\r\n\r\nMEXC Futures API for create orders is on maintance now. **_But you can bypass it_**. See [this issue](https://github.com/makarworld/pymexc/issues/15) for more information.\r\n\r\n# Installation\r\n\r\nYou can install pymexc using pip:\r\n\r\n```bash\r\npip install pymexc\r\n```\r\n\r\n# Getting Started\r\n\r\nTo start working with pymexc, you must import spot or futures from the library. Each of them contains 2 classes: HTTP and WebSocket. To work with simple requests, you need to initialize the HTTP class. To work with web sockets you need to initialize the WebSocket class \r\n\r\n## Example\r\n\r\n```python\r\nfrom pymexc import spot, futures\r\n\r\napi_key = \"YOUR API KEY\"\r\napi_secret = \"YOUR API SECRET KEY\"\r\n\r\ndef handle_message(message): \r\n    # handle websocket message\r\n    print(message)\r\n\r\n\r\n# SPOT V3\r\n\r\n# initialize HTTP client\r\nspot_client = spot.HTTP(api_key = api_key, api_secret = api_secret)\r\n# initialize WebSocket client\r\nws_spot_client = spot.WebSocket(api_key = api_key, api_secret = api_secret)\r\n\r\n# make http request to api\r\nprint(spot_client.exchange_info())\r\n\r\n# create websocket connection to public channel (spot@public.deals.v3.api@BTCUSDT)\r\n# all messages will be handled by function `handle_message`\r\nws_spot_client.deals_stream(handle_message, \"BTCUSDT\")\r\n\r\n\r\n# FUTURES V1\r\n\r\n# initialize HTTP client\r\nfutures_client = futures.HTTP(api_key = api_key, api_secret = api_secret)\r\n# initialize WebSocket client\r\nws_futures_client = futures.WebSocket(api_key = api_key, api_secret = api_secret, \r\n                                      # subscribe on personal information about about account\r\n                                      # if not provided, will not be subscribed\r\n                                      # you can subsctibe later by calling ws_futures_client.personal_stream(callback) for all info\r\n                                      # or ws_futures_client.filter_stream(callback, params={\"filters\":[{\"filter\":\"...\"}]}) for specific info (https://mexcdevelop.github.io/apidocs/contract_v1_en/#filter-subscription)\r\n                                      personal_callback = handle_message)\r\n\r\n# make http request to api\r\nprint(futures_client.index_price(\"MX_USDT\"))\r\n\r\n# create websocket connection to public channel (sub.tickers)\r\n# all messages will be handled by function `handle_message`\r\nws_futures_client.tickers_stream(handle_message)\r\n\r\n# loop forever for save websocket connection \r\nwhile True: \r\n    ...\r\n```\r\n\r\n# Documentation\r\n\r\nYou can find the official documentation for the MEXC API [here](https://mexcdevelop.github.io/apidocs/spot_v3_en/#introduction).\r\n\r\n# License\r\n\r\nThis library is licensed under the MIT License.\r\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Unofficial python library for interacting with the MEXC crypto exchange",
    "version": "1.2.11",
    "project_urls": {
        "Bug Reports": "https://github.com/makarworld/pymexc/issues",
        "Download": "https://github.com/makarworld/pymexc/archive/refs/tags/v1.2.11.zip",
        "Homepage": "https://github.com/makarworld/pymexc.git",
        "Source": "https://github.com/makarworld/pymexc"
    },
    "split_keywords": [
        "mexc",
        " mexc api",
        " mexc api v1",
        " mexc futures bypass",
        " mexc api v2",
        " mexc api v3",
        " mexc spot",
        " mexc futures",
        " mexc websocket",
        " mexc http",
        " mexc rest"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "efc98cc54155fc3f229d136e8a478e793319f97813b7fcfc5a2d26b24d91ace0",
                "md5": "50aeccb0b61ad35ea07d60ad6f489ea8",
                "sha256": "e906f9a8d0f18c9e5d58b532bc1cca9d5e3e56ad4352f88ce08cfb2a43ee763e"
            },
            "downloads": -1,
            "filename": "pymexc-1.2.11-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "50aeccb0b61ad35ea07d60ad6f489ea8",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6.0",
            "size": 78615,
            "upload_time": "2025-08-09T13:49:34",
            "upload_time_iso_8601": "2025-08-09T13:49:34.147762Z",
            "url": "https://files.pythonhosted.org/packages/ef/c9/8cc54155fc3f229d136e8a478e793319f97813b7fcfc5a2d26b24d91ace0/pymexc-1.2.11-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "7d935010cdcb49a6adc0386917518025337aee1b5d4822e11b0d82c94e1d55e1",
                "md5": "cc12efcd0ef01896cad22b02e348dd4a",
                "sha256": "c2b2696d1cb74f220c02c7dbfbf74695f8b4689f293956c00a63d293d703efda"
            },
            "downloads": -1,
            "filename": "pymexc-1.2.11.tar.gz",
            "has_sig": false,
            "md5_digest": "cc12efcd0ef01896cad22b02e348dd4a",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6.0",
            "size": 67357,
            "upload_time": "2025-08-09T13:49:35",
            "upload_time_iso_8601": "2025-08-09T13:49:35.532598Z",
            "url": "https://files.pythonhosted.org/packages/7d/93/5010cdcb49a6adc0386917518025337aee1b5d4822e11b0d82c94e1d55e1/pymexc-1.2.11.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-09 13:49:35",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "makarworld",
    "github_project": "pymexc",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [
        {
            "name": "curl-cffi",
            "specs": [
                [
                    "==",
                    "0.11.1"
                ]
            ]
        },
        {
            "name": "websocket-client",
            "specs": [
                [
                    "==",
                    "1.8.0"
                ]
            ]
        },
        {
            "name": "wsaccel",
            "specs": [
                [
                    "==",
                    "0.6.7"
                ]
            ]
        },
        {
            "name": "websockets",
            "specs": [
                [
                    "==",
                    "15.0.1"
                ]
            ]
        },
        {
            "name": "protobuf",
            "specs": [
                [
                    "==",
                    "6.31.1"
                ]
            ]
        },
        {
            "name": "python-dotenv",
            "specs": [
                [
                    "==",
                    "1.1.0"
                ]
            ]
        },
        {
            "name": "pytest",
            "specs": [
                [
                    "==",
                    "8.4.0"
                ]
            ]
        },
        {
            "name": "pytest-asyncio",
            "specs": [
                [
                    "==",
                    "1.0.0"
                ]
            ]
        },
        {
            "name": "aiohttp",
            "specs": [
                [
                    "==",
                    "3.12.9"
                ]
            ]
        }
    ],
    "lcname": "pymexc"
}
        
Elapsed time: 1.06415s