Skip to content

Commit

Permalink
Merge pull request #239 from Davi0kProgramsThings/v3.0.0
Browse files Browse the repository at this point in the history
Merge branch ` Davi0kProgramsThings:v3.0.0` into branch `bitfinexcom:master`.
  • Loading branch information
itsdeka authored Apr 7, 2024
2 parents bdd78a8 + 354aa62 commit 08b5364
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 34 deletions.
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

0 comments on commit 08b5364

Please sign in to comment.