The Settle SDK abstracts using the price feed and settle API by wrapping authentication in a function.
Project description
Settle SDK
The Settle SDK abstracts using the price feed and settle API by wrapping authentication in a function.
pip install settlesdk
Versions
0.0.4v Fixed GUID from Token 0.0.7v Fixed GUID to Username
How it works
Instead of authenticating and running requests yourself, use the settle object to run api functions.
For example
from settlesdk import PriceList
pricelist = PriceList()
coins = pricelist.ticker({'id': 1})
Important - Authentication
You need to register an app in settle in order to use the API. Head over to https://settle.finance/app/developer-tools and join our developer program.
Set an app name and grab the automatically generated API keys. Update your .env file in your projects root so that SETTLE_API_KEY and SETTLE_API_SECRET reflect your keys. If your app doesn't use environment variables yet, you will need to setup a loader like dotenv.
SETTLE_API_KEY = "API KEY HERE"
SETTLE_API_SECRET = "API SECRET HERE"
You can now access the Settle SDK!
Testing user specific endpoints
You can access the price feed API, but to access a users portfolio they need to install your app and opt into providing their data to you.
In your developer tools, https://settle.finance/app/developer-tools, select "portfolio" in data access permissions and click the install button to try opting into your app before it's available in the app store.
API reference
User specific apps
When your app or chat plugin is loaded inside of settle, we will pass a user_id get param (?user_id) along with the app mode (?mode).
Exchange token for a user id
from settlesdk import User
user = User()
user.exchangeTokenForGuid({'token': token})
Examples
Return ticker information about Bitcoin
from settlesdk import PriceFeed
pricefeed = PriceFeed()
pricefeed.ticker({'token': token})
Convert a GUID to a username
from settlesdk import User
user = User()
user.guid_to_username({'token': token})
Send an custom hub event
from settlesdk import Chat
chat = Chat()
chat.sendEvent({ chatId, message })
Send a notification to a user
from settlesdk import App
app = App()
app.send_notification({guid: guid})
Return a users holdings with a list of trades for each asset
from settlesdk import Portfolio
portfolio = Portfolio()
portfolio.HoldingsWithTrades({ 'guid': user_id })
Return a list of users who installed my app
from settlesdk import App
app = App()
app.users()
Send Notification to users with installed app
from settlesdk import App
app = App()
users = app.users()
for user in users:
app.send_notification({'guid': user.guid})
Return Requests response with data
from settlesdk import App
app = App()
users, response = app.user(include_response=True)
print(response.status_code)
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for settlesdk-0.0.7-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | efdad805e878d1e4098c9cc32b56bbe3be6182629e263f074db06063e16a64af |
|
MD5 | 216a01c5e121ec1b11c1ea51b5970836 |
|
BLAKE2b-256 | e73dc9e0a97255bd0937a58521e14ff452ff6de7a2dd770edb89c79a0793c4df |