{"id":18383398,"url":"https://github.com/dwolla/dwolla-v2-python","last_synced_at":"2025-04-06T23:32:14.521Z","repository":{"id":8364808,"uuid":"58135128","full_name":"Dwolla/dwolla-v2-python","owner":"Dwolla","description":"Official Python Wrapper for Dwolla's API","archived":false,"fork":false,"pushed_at":"2022-12-08T13:39:13.000Z","size":115,"stargazers_count":25,"open_issues_count":3,"forks_count":17,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-03-22T09:12:00.822Z","etag":null,"topics":["api","dwolla","python","sdk","sdk-python"],"latest_commit_sha":null,"homepage":"https://developers.dwolla.com","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Dwolla.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-05-05T14:05:21.000Z","updated_at":"2024-03-06T03:05:42.000Z","dependencies_parsed_at":"2023-01-11T17:22:21.443Z","dependency_job_id":null,"html_url":"https://github.com/Dwolla/dwolla-v2-python","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dwolla%2Fdwolla-v2-python","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dwolla%2Fdwolla-v2-python/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dwolla%2Fdwolla-v2-python/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Dwolla%2Fdwolla-v2-python/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Dwolla","download_url":"https://codeload.github.com/Dwolla/dwolla-v2-python/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247569124,"owners_count":20959758,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","dwolla","python","sdk","sdk-python"],"created_at":"2024-11-06T01:11:15.550Z","updated_at":"2025-04-06T23:32:11.491Z","avatar_url":"https://github.com/Dwolla.png","language":"Python","readme":"# Dwolla SDK for Python\n\nThis repository contains the source code for Dwolla's Python-based SDK, which allows developers to interact with Dwolla's server-side API via a Python API. Any action that can be performed via an HTTP request can be made using this SDK when executed within a server-side environment.\n\n## Table of Contents\n\n- [Getting Started](#getting-started)\n  - [Installation](#installation)\n  - [Initialization](#initialization)\n    - [Tokens](#tokens)\n- [Making Requests](#making-requests)\n  - [Low-level Requests](#low-level-requests)\n    - [Setting Headers](#setting-headers)\n    - [Responses](#responses)\n      - [Success](#success)\n      - [Error](#error)\n  - [Example App](#example-app)\n- [Changelog](#changelog)\n- [Community](#community)\n- [Additional Resources](#additional-resources)\n\n## Getting Started\n\n### Installation\n\nTo begin using this SDK, you will first need to download it to your machine. We use [PyPi](https://pypi.python.org/pypi/dwollav2) to distribute this package from where you can automagically download it via [pip](https://pip.pypa.io/en/stable/installing/).\n\n```shell\n$ pip install dwollav2\n```\n\n### Initialization\n\nBefore any API requests can be made, you must first determine which environment you will be using, as well as fetch the application key and secret. To fetch your application key and secret, please visit one of the following links:\n\n- Production: https://dashboard.dwolla.com/applications\n- Sandbox: https://dashboard-sandbox.dwolla.com/applications\n\nFinally, you can create an instance of `Client` with `key` and `secret` replaced with the application key and secret that you fetched from one of the aforementioned links, respectively.\n\n```python\nclient = dwollav2.Client(\n  key = os.environ['DWOLLA_APP_KEY'],\n  secret = os.environ['DWOLLA_APP_SECRET'],\n  environment = 'sandbox', # defaults to 'production'\n  requests = {'timeout': 0.001}\n)\n```\n\n##### Configure an `on_grant` callback (optional)\n\nAn `on_grant` callback is useful for storing new tokens when they are granted. The `on_grant`\ncallback is called with the `Token` that was just granted by the server.\n\n```python\nclient = dwollav2.Client(\n  key = os.environ['DWOLLA_APP_KEY'],\n  secret = os.environ['DWOLLA_APP_SECRET'],\n  on_grant = lambda t: save(t)\n)\n```\n\nIt is highly recommended that you encrypt any token data you store.\n\n#### Tokens\n\n##### Generating New Access Tokens\n\nApplication access tokens are used to authenticate against the API on behalf of an application. Application tokens can be used to access resources in the API that either belong to the application itself (`webhooks`, `events`, `webhook-subscriptions`) or the Dwolla Account that owns the application (`accounts`, `customers`, `funding-sources`, etc.). Application tokens are obtained by using the [`client_credentials`](https://tools.ietf.org/html/rfc6749#section-4.4) OAuth grant type:\n\n```python\napplication_token = client.Auth.client()\n```\n\n_Application access tokens are short-lived: 1 hour. They do not include a `refresh_token`. When it expires, generate a new one using `client.Auth.client()`._\n\n##### Initializing Pre-Existing Tokens:\n\nThe [Dwolla Sandbox Dashboard](https://dashboard-sandbox.dwolla.com/applications-legacy) allows you to generate tokens for your application. A `Token` can be initialized with the following attributes:\n\n```python\nclient.Token(access_token = '...',\n             expires_in = 123)\n```\n\n## Making Requests\n\nOnce you've created a `Token`, currently, you can make low-level HTTP requests.\n\n### Low-level Requests\n\nTo make low-level HTTP requests, you can use the `get()`, `post()`, and `delete()` methods. These methods will return a `Response` object.\n\n#### `GET`\n\n```python\n# GET api.dwolla.com/resource?foo=bar\ntoken.get('resource', foo = 'bar')\n\n# GET requests can also use objects as parameters\n# GET api.dwolla.com/resource?foo=bar\ntoken.get('resource', {'foo' = 'bar', 'baz' = 'foo'})\n```\n\n#### `POST`\n\n```python\n# POST api.dwolla.com/resource {\"foo\":\"bar\"}\ntoken.post('resource', foo = 'bar')\n\n# POST api.dwolla.com/resource multipart/form-data foo=...\ntoken.post('resource', foo = ('mclovin.jpg', open('mclovin.jpg', 'rb'), 'image/jpeg'))\n```\n\n#### `DELETE`\n\n```python\n# DELETE api.dwolla.com/resource\ntoken.delete('resource')\n```\n\n#### Setting headers\n\nTo set additional headers on a request you can pass a `dict` of headers as the 3rd argument.\n\nFor example:\n\n```python\ntoken.post('customers', { 'firstName': 'John', 'lastName': 'Doe', 'email': 'jd@doe.com' },\n                        { 'Idempotency-Key': 'a52fcf63-0730-41c3-96e8-7147b5d1fb01' })\n```\n\n#### Responses\n\nThe following snippets demonstrate successful and errored responses from the Dwolla API.\n\nAn errored response is returned when Dwolla's servers respond with a status code that is greater than or equal to 400, whereas a successful response is when Dwolla's servers respond with a 200-level status code.\n\n##### Success\n\n```python\nres = token.get('/')\n\nres.status\n# =\u003e 200\n\nres.headers\n# =\u003e {'server'=\u003e'cloudflare-nginx', 'date'=\u003e'Mon, 28 Mar 2016 15:30:23 GMT', 'content-type'=\u003e'application/vnd.dwolla.v1.hal+json; charset=UTF-8', 'content-length'=\u003e'150', 'connection'=\u003e'close', 'set-cookie'=\u003e'__cfduid=d9dcd0f586c166d36cbd45b992bdaa11b1459179023; expires=Tue, 28-Mar-17 15:30:23 GMT; path=/; domain=.dwolla.com; HttpOnly', 'x-request-id'=\u003e'69a4e612-5dae-4c52-a6a0-2f921e34a88a', 'cf-ray'=\u003e'28ac1f81875941e3-MSP'}\n\nres.body['_links']['events']['href']\n# =\u003e 'https://api-sandbox.dwolla.com/events'\n```\n\n##### Error\n\nIf the server returns an error, a `dwollav2.Error` (or one of its subclasses) will be raised.\n`dwollav2.Error`s are similar to `Response`s.\n\n```python\ntry:\n  token.get('/not-found')\nexcept dwollav2.NotFoundError as e:\n  e.status\n  # =\u003e 404\n\n  e.headers\n  # =\u003e {\"server\"=\u003e\"cloudflare-nginx\", \"date\"=\u003e\"Mon, 28 Mar 2016 15:35:32 GMT\", \"content-type\"=\u003e\"application/vnd.dwolla.v1.hal+json; profile=\\\"http://nocarrier.co.uk/profiles/vnd.error/\\\"; charset=UTF-8\", \"content-length\"=\u003e\"69\", \"connection\"=\u003e\"close\", \"set-cookie\"=\u003e\"__cfduid=da1478bfdf3e56275cd8a6a741866ccce1459179332; expires=Tue, 28-Mar-17 15:35:32 GMT; path=/; domain=.dwolla.com; HttpOnly\", \"access-control-allow-origin\"=\u003e\"*\", \"x-request-id\"=\u003e\"667fca74-b53d-43db-bddd-50426a011881\", \"cf-ray\"=\u003e\"28ac270abca64207-MSP\"}\n\n  e.body.code\n  # =\u003e \"NotFound\"\nexcept dwollav2.Error:\n  # ...\n```\n\n###### `dwollav2.Error` subclasses:\n\n_See https://developers.dwolla.com/api-reference#errors for more info._\n\n- `dwollav2.AccessDeniedError`\n- `dwollav2.InvalidCredentialsError`\n- `dwollav2.NotFoundError`\n- `dwollav2.BadRequestError`\n- `dwollav2.InvalidGrantError`\n- `dwollav2.RequestTimeoutError`\n- `dwollav2.ExpiredAccessTokenError`\n- `dwollav2.InvalidRequestError`\n- `dwollav2.ServerError`\n- `dwollav2.ForbiddenError`\n- `dwollav2.InvalidResourceStateError`\n- `dwollav2.TemporarilyUnavailableError`\n- `dwollav2.InvalidAccessTokenError`\n- `dwollav2.InvalidScopeError`\n- `dwollav2.UnauthorizedClientError`\n- `dwollav2.InvalidAccountStatusError`\n- `dwollav2.InvalidScopesError`\n- `dwollav2.UnsupportedGrantTypeError`\n- `dwollav2.InvalidApplicationStatusError`\n- `dwollav2.InvalidVersionError`\n- `dwollav2.UnsupportedResponseTypeError`\n- `dwollav2.InvalidClientError`\n- `dwollav2.MethodNotAllowedError`\n- `dwollav2.ValidationError`\n- `dwollav2.TooManyRequestsError`\n- `dwollav2.ConflictError`\n\n### Example App\n\nTake a look at the\n[Sample Application](https://github.com/Dwolla/dwolla-v2-python/tree/main/sample_app) for examples\non how to use this SDK to call the Dwolla API. Before you can begin using the app, however,\nyou will need to specify a `DWOLLA_APP_KEY` and `DWOLLA_APP_SECRET` environment variable.\n\n## Changelog\n\n- **2.2.1**\n  - Add extra check in URL's to ensure they are clean. [#36](https://github.com/Dwolla/dwolla-v2-python/pull/36).\n- **2.2.0**\n  - Update JSON request bodies to serialize via `simplejson` so datatypes like `Decimal` still\n    serialize like they did pre `2.0.0`\n- **2.1.0**\n  - Do not share `requests.session()` across instances of `dwollav2.Client`\n- **2.0.0**\n  - JSON request bodies now contain sorted keys to ensure the same request body for a given set of\n    arguments, no matter the order they are passed to `dwolla.post`. This ensures the\n    [`Idempotency-Key`][] header will work as intended without additional effort by developers.\n  - **NOTE**: Because this change alters the formatting of JSON request bodies, we are releasing it\n    as a major new version. The request body of a request made with `1.6.0` will not match the\n    request body of the same request made in `2.0.0`. This will nullify the effect of the\n    [`Idempotency-Key`][] header when upgrading, so please take this into account.\n    If you have any questions please [reach out to us](https://discuss.dwolla.com/)!\n    There are no other changes since `1.6.0`.\n- **1.6.0** Allow configuration of `requests` options on `dwollav2.Client`.\n- **1.5.0** Add integrations auth functionality\n- **1.4.0** ~~Pass kwargs from `get`, `post`, and `delete` methods to underlying requests methods.~~ (Removed in v1.6)\n- **1.3.0** Change token URLs, update dependencies.\n- **1.2.4** Create a new session for each Token.\n- **1.2.3** Check if IOBase when checking to see if something is a file.\n- **1.2.2** Strip domain from URLs provided to token.\\* methods.\n- **1.2.1** Update sandbox URLs from uat =\u003e sandbox.\n- **1.2.0** Refer to Client id as key.\n- **1.1.8** Support `verified_account` and `dwolla_landing` auth flags\n- **1.1.7** Use session over connections for [performance improvement](http://docs.python-requests.org/en/master/user/advanced/#session-objects) ([#8](https://github.com/Dwolla/dwolla-v2-python/pull/8) - Thanks [@bfeeser](https://github.com/bfeeser)!\n- **1.1.5** Fix file upload bug when using with Python 2 ([#6](https://github.com/Dwolla/dwolla-v2-python/issues/6))\n- **1.1.2** Add `TooManyRequestsError` and `ConflictError`\n- **1.1.1** Add MANIFEST.in\n- **1.1.0** Support per-request headers\n\n## Community\n\n- If you have any feedback, please reach out to us on [our forums](https://discuss.dwolla.com/) or by [creating a GitHub issue](https://github.com/Dwolla/dwolla-v2-python/issues/new).\n- If you would like to contribute to this library, [bug reports](https://github.com/Dwolla/dwolla-v2-python/issues) and [pull requests](https://github.com/Dwolla/dwolla-v2-python/pulls) are always appreciated!\n  - After checking out the repo, run `pip install -r requirements.txt` to install dependencies. Then, run `python setup.py` test to run the tests.\n  - To install this gem onto your local machine, `run pip install -e .`.\n\n## Docker\n\nIf you prefer to use Docker to run dwolla-v2-python locally, a Dockerfile is included at the root directory.\nFollow these instructions from [Docker's website](https://docs.docker.com/build/hellobuild/) to create a Docker image from the Dockerfile, and run it.\n\n## Additional Resources\n\nTo learn more about Dwolla and how to integrate our product with your application, please consider visiting the following resources and becoming a member of our community!\n\n- [Dwolla](https://www.dwolla.com/)\n- [Dwolla Developers](https://developers.dwolla.com/)\n- [SDKs and Tools](https://developers.dwolla.com/sdks-tools)\n  - [Dwolla SDK for C#](https://github.com/Dwolla/dwolla-v2-csharp)\n  - [Dwolla SDK for Kotlin](https://github.com/Dwolla/dwolla-v2-kotlin)\n  - [Dwolla SDK for Node](https://github.com/Dwolla/dwolla-v2-node)\n  - [Dwolla SDK for PHP](https://github.com/Dwolla/dwolla-swagger-php)\n  - [Dwolla SDK for Ruby](https://github.com/Dwolla/dwolla-v2-ruby)\n- [Developer Support Forum](https://discuss.dwolla.com/)\n\n[`idempotency-key`]: https://docs.dwolla.com/#idempotency-key\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwolla%2Fdwolla-v2-python","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwolla%2Fdwolla-v2-python","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwolla%2Fdwolla-v2-python/lists"}