Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge branch Davi0kProgramsThings:v3.0.0 into branch bitfinexcom:master. #239

Merged
merged 4 commits into from
Apr 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
# bitfinex-api-py (v3-beta)
# bitfinex-api-py

Official implementation of the [Bitfinex APIs (V2)](https://docs.bitfinex.com/docs) for `Python 3.8+`.

> **DISCLAIMER:** \
Production use of v3.0.0b1 (and all future beta versions) is HIGHLY discouraged. \
Beta versions should not be used in applications which require user authentication. \
Provide your API-KEY/API-SECRET, and manage your account and funds at your own risk.

### Features

* Support for 75+ REST endpoints (a list of available endpoints can be found [here](https://docs.bitfinex.com/reference))
Expand All @@ -20,13 +15,6 @@ Provide your API-KEY/API-SECRET, and manage your account and funds at your own r
python3 -m pip install --pre bitfinex-api-py
```

### Selecting and installing a specific beta version

It's also possible to select and install a specific beta version:
```console
python3 -m pip install bitfinex-api-py==3.0.0b1
```

---

# Quickstart
Expand Down Expand Up @@ -305,7 +293,7 @@ All contributions are welcome! :D

A guide on how to install and set up `bitfinex-api-py`'s source code can be found [here](#installation-and-setup). \
Before opening any pull requests, please have a look at [Before Opening a PR](#before-opening-a-pr). \
Contributors must uphold the [Contributor Covenant code of conduct](https://github.com/bitfinexcom/bitfinex-api-py/blob/v3-beta/CODE_OF_CONDUCT.md).
Contributors must uphold the [Contributor Covenant code of conduct](https://github.com/bitfinexcom/bitfinex-api-py/blob/master/CODE_OF_CONDUCT.md).

### Index

Expand All @@ -323,10 +311,8 @@ A brief guide on how to install and set up the project in your Python 3.8+ envir

### Cloning the repository

The following command will only clone the `v3-beta` branch (excluding all others):

```console
git clone --branch v3-beta --single-branch https://github.com/bitfinexcom/bitfinex-api-py.git
git clone https://github.com/bitfinexcom/bitfinex-api-py.git
```

### Installing the dependencies
Expand Down
2 changes: 1 addition & 1 deletion bfxapi/_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = "3.0.0b5"
__version__ = "3.0.0"
28 changes: 15 additions & 13 deletions bfxapi/rest/_interface/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
import json
from datetime import datetime
from enum import IntEnum
from typing import TYPE_CHECKING, Any, List, Optional
from typing import TYPE_CHECKING, Any, List, NoReturn, Optional

import requests

from bfxapi._utils.json_decoder import JSONDecoder
from bfxapi._utils.json_encoder import JSONEncoder
from bfxapi.exceptions import InvalidCredentialError
from bfxapi.rest.exceptions import RequestParametersError, UnknownGenericError
from bfxapi.rest.exceptions import GenericError, RequestParameterError

if TYPE_CHECKING:
from requests.sessions import _Params
Expand Down Expand Up @@ -86,28 +86,30 @@ def post(

return data

def __handle_error(self, error: List[Any]) -> None:
def __handle_error(self, error: List[Any]) -> NoReturn:
if error[1] == _Error.ERR_PARAMS:
raise RequestParametersError(
"The request was rejected with the following parameter"
f"error: <{error[2]}>"
raise RequestParameterError(
"The request was rejected with the following parameter "
f"error: <{error[2]}>."
)

if error[1] == _Error.ERR_AUTH_FAIL:
raise InvalidCredentialError(
"Cannot authenticate with given API-KEY and API-SECRET."
"Can't authenticate with given API-KEY and API-SECRET."
)

if not error[1] or error[1] == _Error.ERR_UNK or error[1] == _Error.ERR_GENERIC:
raise UnknownGenericError(
"The server replied to the request with a generic error with "
f"the following message: <{error[2]}>."
raise GenericError(
"The request was rejected with the following generic "
f"error: <{error[2]}>."
)

raise RuntimeError(
f"The request was rejected with an unexpected error: <{error}>."
)

def __get_authentication_headers(self, endpoint: str, data: Optional[str] = None):
assert (
self.__api_key and self.__api_secret
), "API-KEY and API-SECRET must be strings."
assert self.__api_key and self.__api_secret

nonce = str(round(datetime.now().timestamp() * 1_000_000))

Expand Down
4 changes: 2 additions & 2 deletions bfxapi/rest/exceptions.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from bfxapi.exceptions import BfxBaseException


class RequestParametersError(BfxBaseException):
class RequestParameterError(BfxBaseException):
pass


class UnknownGenericError(BfxBaseException):
class GenericError(BfxBaseException):
pass
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
author_email="[email protected]",
license="Apache-2.0",
classifiers=[
"Development Status :: 4 - Beta",
"Development Status :: 5 - Production/Stable",
"Intended Audience :: Developers",
"Topic :: Software Development :: Build Tools",
"License :: OSI Approved :: Apache Software License",
Expand Down
Loading