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

Allow addition of multiple api keys per exchange #2780

Merged
merged 14 commits into from
May 1, 2021
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
85 changes: 68 additions & 17 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,11 @@ Handling user creation, sign-in, log-out and querying

{
"result": {
"exchanges": ["kraken", "poloniex", "binance"],
"exchanges": [
{"location": "kraken", "name": "kraken1"},
{"location": "poloniex", "name": "poloniex1"},
{"location": "binance", "name": "binance1"}
],
"settings": {
"have_premium": true,
"version": "6",
Expand All @@ -145,7 +149,6 @@ Handling user creation, sign-in, log-out and querying
"date_display_format": "%d/%m/%Y %H:%M:%S %Z",
"last_balance_save": 1571552172,
"submit_usage_analytics": true,
"kraken_account_type": "intermediate",
"active_modules": ["makerdao_dsr", "makerdao_vaults", "aave"],
"current_price_oracles": ["cryptocompare", "coingecko"],
"historical_price_oracles": ["cryptocompare", "coingecko"],
Expand Down Expand Up @@ -192,7 +195,11 @@ Handling user creation, sign-in, log-out and querying

{
"result": {
"exchanges": ["kraken", "poloniex", "binance"],
"exchanges": [
{"location": "kraken", "name": "kraken1"},
{"location": "poloniex", "name": "poloniex1"},
{"location": "binance", "name": "binance1"}
],
"settings": {
"have_premium": true,
"version": "6",
Expand All @@ -211,7 +218,6 @@ Handling user creation, sign-in, log-out and querying
"date_display_format": "%d/%m/%Y %H:%M:%S %Z",
"last_balance_save": 1571552172,
"submit_usage_analytics": true,
"kraken_account_type": "intermediate",
"active_modules": ["makerdao_dsr", "makerdao_vaults", "aave"],
"current_price_oracles": ["cryptocompare", "coingecko"],
"historical_price_oracles": ["cryptocompare", "coingecko"],
Expand Down Expand Up @@ -583,7 +589,6 @@ Getting or modifying settings
"date_display_format": "%d/%m/%Y %H:%M:%S %Z",
"last_balance_save": 1571552172,
"submit_usage_analytics": true,
"kraken_account_type": "intermediate",
"active_modules": ["makerdao_dsr", "makerdao_vaults", "aave"],
"current_price_oracles": ["coingecko"],
"historical_price_oracles": ["cryptocompare", "coingecko"],
Expand All @@ -610,7 +615,6 @@ Getting or modifying settings
:resjson string date_display_format: The format in which to display dates in the UI. Default is ``"%d/%m/%Y %H:%M:%S %Z"``.
:resjson int last_balance_save: The timestamp at which the balances were last saved in the database.
:resjson bool submit_usage_analytics: A boolean denoting wether or not to submit anonymous usage analytics to the Rotki server.
:resjson string kraken_account_type: The type of the user's kraken account if he has one. Valid values are "starter", "intermediate" and "pro".
:resjson list active_module: A list of strings denoting the active modules with which Rotki is running.
:resjson list current_price_oracles: A list of strings denoting the price oracles rotki should query in specific order for requesting current prices.
:resjson list historical_price_oracles: A list of strings denoting the price oracles rotki should query in specific order for requesting historical prices.
Expand Down Expand Up @@ -682,7 +686,6 @@ Getting or modifying settings
"date_display_format": "%d/%m/%Y %H:%M:%S %Z",
"last_balance_save": 1571552172,
"submit_usage_analytics": true,
"kraken_account_type": "intermediate",
"active_modules": ["makerdao_dsr", "makerdao_vaults", "aave"],
"current_price_oracles": ["cryptocompare"],
"historical_price_oracles": ["coingecko", "cryptocompare"],
Expand Down Expand Up @@ -981,7 +984,7 @@ Get a list of setup exchanges

.. http:get:: /api/(version)/exchanges

Doing a GET on this endpoint will return a list of which exchanges are currently setup for the logged in user.
Doing a GET on this endpoint will return a list of which exchanges are currently setup for the logged in user and with which names.

**Example Request**:

Expand All @@ -998,11 +1001,15 @@ Get a list of setup exchanges
Content-Type: application/json

{
"result": ["kraken", "binance"]
"result": [
{"location": "kraken", "name": "kraken1"},
{"location": "poloniex", "name": "poloniex1"},
{"location": "binance", "name": "binance1"}
],
"message": ""
}

:resjson list result: A list of exchange names that have been setup for the logged in user.
:resjson list result: A list of exchange location/name pairs that have been setup for the logged in user.
:statuscode 200: The exchanges list has been sucesfully setup
:statuscode 409: No user is logged in.
:statuscode 500: Internal Rotki error
Expand All @@ -1012,7 +1019,7 @@ Setup or remove an exchange

.. http:put:: /api/(version)/exchanges

Doing a PUT on this endpoint with an exchange's name, api key and secret will setup the exchange for the current user.
Doing a PUT on this endpoint with an exchange's name, location, api key and secret will setup the exchange for the current user. Also for some exchanges additional optional info can be provided.

**Example Request**:

Expand All @@ -1022,12 +1029,14 @@ Setup or remove an exchange
Host: localhost:5042
Content-Type: application/json;charset=UTF-8

{"name": "kraken", "api_key": "ddddd", "api_secret": "ffffff", "passphrase": "secret"}
{"name": "my kraken key", "location": "kraken", "api_key": "ddddd", "api_secret": "ffffff", "passphrase": "secret"}

:reqjson string name: The name of the exchange to setup
:reqjson string name: A name to give to this exchange's key
:reqjson string location: The location of the exchange to setup
:reqjson string api_key: The api key with which to setup the exchange
:reqjson string api_secret: The api secret with which to setup the exchange
:reqjson string passphrase: An optional passphrase, only for exchanges, like coinbase pro, which need a passphrase.
:reqjson string kraken_account_type: An optional setting for kraken. The type of the user's kraken account. Valid values are "starter", "intermediate" and "pro".

**Example Response**:

Expand Down Expand Up @@ -1059,9 +1068,10 @@ Setup or remove an exchange
Host: localhost:5042
Content-Type: application/json;charset=UTF-8

{"name": "kraken"}
{"name": "my kraken key", "location": "kraken"}

:reqjson string name: The name of the exchange to delete
:reqjson string name: The name of the exchange whose key to delete
:reqjson string location: The location of the exchange to delete

**Example Response**:

Expand All @@ -1081,10 +1091,51 @@ Setup or remove an exchange
:statuscode 409: No user is logged in. The exchange is not registered or some other error
:statuscode 500: Internal Rotki error

Edit an exchange entry
========================

.. http:patch:: /api/(version)/exchanges

Doing a PATCH on this endpoint with an exchange's name and location and the various optional attributes will result in editing it.

**Example Request**:

.. http:example:: curl wget httpie python-requests

PATCH /api/1/exchanges HTTP/1.1
Host: localhost:5042
Content-Type: application/json;charset=UTF-8

{"name": "my kraken key", "location": "kraken", "new_name": "my_kraken", "passphrase": "secret", "kraken_account_type": "intermediate"}

:reqjson string name: The name of the exchange key to edit
:reqjson string location: The location of the exchange to edit
:reqjson string new_name: Optional. If given this will be the new name for the exchange credentials.
:reqjson string passphrase: Optional. If given this will be the new passphrase. Only for exchanges, like coinbase pro, which need a passphrase.
:reqjson string kraken_account_type: Optional. An optional setting for kraken. The type of the user's kraken account. Valid values are "starter", "intermediate" and "pro".

**Example Response**:

.. sourcecode:: http

HTTP/1.1 200 OK
Content-Type: application/json

{
"result": true
"message": ""
}

:resjson bool result: A boolean indicating success if all went well. If there is an error then the usual result: null and message having a value format is followed.
:statuscode 200: The exchange has been sucesfully edited
:statuscode 400: Provided JSON is in some way malformed
:statuscode 409: No user is logged in. The exchange can not be found.
:statuscode 500: Internal Rotki error

Querying the balances of exchanges
====================================

.. http:get:: /api/(version)/exchanges/balances/(name)
.. http:get:: /api/(version)/exchanges/balances/(location)

Doing a GET on the appropriate exchanges balances endpoint will return the balances of all assets currently held in that exchange. If no name is provided then the balance of all exchanges is returned.

Expand Down Expand Up @@ -1176,7 +1227,7 @@ Querying the balances of exchanges
Purging locally saved data for exchanges
=========================================

.. http:delete:: /api/(version)/exchanges/data/(name)
.. http:delete:: /api/(version)/exchanges/data/(location)

Doing a DELETE on the appropriate exchanges trades endpoint will delete the cached trades, deposits and withdrawals for that exchange. If no exchange is given then all exchanges will be affected. Next time exchange history is queried, everything will be queried again, and may take some time.

Expand Down
4 changes: 2 additions & 2 deletions frontend/app/src/components/history/consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { TradeLocationData } from '@/components/history/type';
import {
EXCHANGE_BALANCER,
EXCHANGE_BINANCE,
EXCHANGE_BINANCE_US,
EXCHANGE_BINANCEUS,
EXCHANGE_BITCOIN_DE,
EXCHANGE_BITFINEX,
EXCHANGE_BITMEX,
Expand Down Expand Up @@ -59,7 +59,7 @@ export const tradeLocations: TradeLocationData[] = [
exchange: true
},
{
identifier: EXCHANGE_BINANCE_US,
identifier: EXCHANGE_BINANCEUS,
name: 'Binance US',
icon: require('@/assets/images/binance.png'),
imageIcon: true,
Expand Down
2 changes: 1 addition & 1 deletion frontend/app/src/components/import/FileUpload.vue
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<script lang="ts">
import { Component, Emit, Prop, Vue } from 'vue-property-decorator';

const SOURCES = ['cointracking.info', 'crypto.com', 'icon'];
const SOURCES = ['cointracking.info', 'cryptocom', 'icon'];

@Component({})
export default class FileUpload extends Vue {
Expand Down
6 changes: 3 additions & 3 deletions frontend/app/src/data/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ export const EXCHANGE_BINANCE = 'binance';
export const EXCHANGE_COINBASE = 'coinbase';
export const EXCHANGE_COINBASEPRO = 'coinbasepro';
export const EXCHANGE_GEMINI = 'gemini';
export const EXCHANGE_CRYPTOCOM = 'crypto.com';
export const EXCHANGE_CRYPTOCOM = 'cryptocom';
export const EXCHANGE_BITSTAMP = 'bitstamp';
export const EXCHANGE_BINANCE_US = 'binance_us';
export const EXCHANGE_BINANCEUS = 'binanceus';
export const EXCHANGE_BITCOIN_DE = 'bitcoinde';
export const EXCHANGE_ICONOMI = 'iconomi';
export const EXCHANGE_KUCOIN = 'kucoin';
Expand All @@ -54,7 +54,7 @@ export const SUPPORTED_EXCHANGES = [
EXCHANGE_BITMEX,
EXCHANGE_BITFINEX,
EXCHANGE_BINANCE,
EXCHANGE_BINANCE_US,
EXCHANGE_BINANCEUS,
EXCHANGE_BITCOIN_DE,
EXCHANGE_COINBASE,
EXCHANGE_COINBASEPRO,
Expand Down
3 changes: 1 addition & 2 deletions rotkehlchen/accounting/ledger_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from rotkehlchen.history.deserialization import deserialize_price
from rotkehlchen.serialization.deserialize import (
deserialize_asset_amount,
deserialize_location_from_db,
deserialize_optional,
deserialize_timestamp,
)
Expand Down Expand Up @@ -215,7 +214,7 @@ def deserialize_from_db(cls, data: LedgerActionDBTupleWithIdentifier) -> 'Ledger
identifier=data[0],
timestamp=deserialize_timestamp(data[1]),
action_type=LedgerActionType.deserialize_from_db(data[2]),
location=deserialize_location_from_db(data[3]),
location=Location.deserialize_from_db(data[3]),
amount=deserialize_asset_amount(data[4]),
asset=Asset(data[5]),
rate=deserialize_optional(data[6], deserialize_price),
Expand Down