Skip to main content

A Python implementation of SnapTrade API client library

Project description

SnapTrade-Python

A SnapTrade python client library to help you make requests to the SnapTrade API endpoints more easily.

If you need help or have any questions, send us an email at api@snaptrade.com.

Requirements and Installation

Python version requirements

  • Python 3.6 or later

Installation

pip install snaptrade

SnapTradeAPIClient

Before getting started, you will need a clientID and a consumerKey. If you don't have one, please send us an email to get a new one.

Why use SnapTradeAPIClient?

  1. The client uses the clientID and consumerKey that you pass in to sign a request. This ensures that all requests made to the API server are signed and authenticated correctly.
  2. The client ensures that any data passed in through the path params, query params or request body are formatted correctly.
  3. The client formats the API responses and returns a dictionary of the data returned.

How to use SnapTradeAPIClient?

The code block belows shows you to initialize a SnapTradeAPIClient and how to make requests with it.

"""
Your consumerKey should always remain a secret! Never hard code it! 
""" 

from snaptrade.api_client import SnapTradeAPIClient
 
# 1) Initialize a client with your clientID and consumerKey. 
client = SnapTradeAPIClient(clientID, consumerKey)

# 2) Check that the client is able to make a request to the API server. 
api_status_response = client.api_status()
print(api_status_response)

# 3) Create a new user on SnapTrade 
user_id = "userIDProvidedByPartner"
register_response = client.register_user(user_id)

# Note: A user secret is only generated once. It's required to access
# resources for certain endpoints. 

user_secret = register_response.get("userSecret") 

# 4) Get a redirect URI. Users will need this to connect 
# their brokerage to the SnapTrade server.

redirect_uri = client.get_user_login_redirect_uri(user_id, user_secret).get("redirectURI")

# 5) Obtaining account holdings data

holdings = client.get_all_holdings(user_id, user_secret)

# 6) Deleting a user
deleted_response = client.delete_user(user_id)

Check out the documentation below for making requests to other SnapTrade API endpoints using this client

License & copyrights

Licensed under Apache License 2.0.

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

snaptrade-0.0.2.tar.gz (8.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

snaptrade-0.0.2-py3-none-any.whl (8.3 kB view details)

Uploaded Python 3

File details

Details for the file snaptrade-0.0.2.tar.gz.

File metadata

  • Download URL: snaptrade-0.0.2.tar.gz
  • Upload date:
  • Size: 8.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for snaptrade-0.0.2.tar.gz
Algorithm Hash digest
SHA256 fa26e189759beb87c9d7ce2c81ecb013a7ff4f6376494ff9f8a753edd9aa3a43
MD5 ca1401cc0cea41f87a2516516247f3d9
BLAKE2b-256 45e459bfb7e5e645070a5b0ba83811530e455c7ba5ac8b2288ca2a95b339ae71

See more details on using hashes here.

File details

Details for the file snaptrade-0.0.2-py3-none-any.whl.

File metadata

  • Download URL: snaptrade-0.0.2-py3-none-any.whl
  • Upload date:
  • Size: 8.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.9.7

File hashes

Hashes for snaptrade-0.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8fb3626f775f55b5df5160a92038ca8c185a763a0ea1cbf9e5dbc21df04def8d
MD5 78a7747bc6fa343762a7193fcbbfa903
BLAKE2b-256 8da3bde2c6c0a8c47362f7e1132b726ff1a1f1fcc2b1a58d3d2a2f76bb4b4eb9

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page