|
1 |
| -# magic-admin-python |
| 1 | +# Magic Admin Python SDK |
| 2 | + |
| 3 | +The Magic Admin Python SDK provides convenient ways for developers to interact with Magic API endpoints and an array of unitities to handle [DID Token](https://docs.magic.link/tutorials/decentralized-id). |
| 4 | + |
| 5 | +## Table of Contents |
| 6 | + |
| 7 | +* [Documentation](#documentation) |
| 8 | +* [Quick Start](#quick-start) |
| 9 | +* [Development](#development) |
| 10 | +* [Changelog](#changelog) |
| 11 | +* [License](#license) |
| 12 | + |
| 13 | +## Documentation |
| 14 | +See the [Magic doc](https://docs.magic.link/admin-sdk/coming-soon)! (TODO: this to Python section once it is added). |
| 15 | + |
| 16 | +## Installation |
| 17 | +You can directly install the SDK with: |
| 18 | + |
| 19 | +pip: |
| 20 | + |
| 21 | +``` |
| 22 | +pip install magic-admin |
| 23 | +``` |
| 24 | + |
| 25 | +conda: |
| 26 | + |
| 27 | +``` |
| 28 | +conda install magic-admin |
| 29 | +``` |
| 30 | + |
| 31 | +### Prerequisites |
| 32 | + |
| 33 | +- Python 3.6 |
| 34 | + |
| 35 | +**Note**: This package has only been tested with `Python 3.6`. `Python 3.7` and `Python 3.8` have not been tested yet. We will get to it very soon. Support for `Python 2.7+` will not be actively worked on. If you are interested using this package with earlier versions of Python, please create a ticket and let us know :) |
| 36 | + |
| 37 | +## Quick Start |
| 38 | +Before you start, you will need an API secret key. You can get one from the [Magic Dashboard](https://dashboard.magic.link/). Once you have the API secret key, you can instantiate a Magic object. |
| 39 | + |
| 40 | +``` |
| 41 | +from magic_admin import Magic |
| 42 | +
|
| 43 | +magic = Magic(api_secret_key='<YOUR_API_SECRET_KEY>') |
| 44 | +
|
| 45 | +magic.Token.validate('DID_TOKEN') |
| 46 | +
|
| 47 | +# Read the docs to learn more! 🚀 |
| 48 | +``` |
| 49 | + |
| 50 | +Optionally if you would like, you can load the API secret key from the environment variable, `MAGIC_API_SECRET_KEY`. |
| 51 | + |
| 52 | +``` |
| 53 | +# Set the env variable `MAGIC_API_SECRET_KEY`. |
| 54 | +
|
| 55 | +magic = Magic() |
| 56 | +``` |
| 57 | + |
| 58 | +**Note**: The argument passed to the `Magic(...)` object takes precedence over the environment variable. |
| 59 | + |
| 60 | +### Configure Network Strategy |
| 61 | +The `Magic` object also takes in `retries`, `timeout` and `backoff_factor` as optional arguments at the object instantiation time so you can override those values for your application setup. |
| 62 | + |
| 63 | +``` |
| 64 | +magic = Magic(retries=5, timeout=10, backoff_factor=0.03) |
| 65 | +``` |
| 66 | + |
| 67 | +## Development |
| 68 | +We would love to have you contributing to this SDK. To get started, you can clone this repository and create a virtualenv. |
| 69 | + |
| 70 | +``` |
| 71 | +make development |
| 72 | +``` |
| 73 | + |
| 74 | +This will create a virtualenv for all the local development dependencies that the SDK will needs. |
| 75 | + |
| 76 | +Once it is done, you can `source` the virtualenv. It makes your local development easier! |
| 77 | + |
| 78 | +``` |
| 79 | +source virtualenv_run/bin/activate |
| 80 | +``` |
| 81 | + |
| 82 | +To make sure your new code works with the existing SDK, run the test against the current supported Python versions. |
| 83 | + |
| 84 | +``` |
| 85 | +make test |
| 86 | +``` |
| 87 | + |
| 88 | +To clean up existing virtualenv, tox log and pytest cache, do a |
| 89 | + |
| 90 | +``` |
| 91 | +make clean |
| 92 | +``` |
| 93 | + |
| 94 | +This repository is installed with [pre-commit](https://pre-commit.com/). All the pre-commit hooks are run automatically with every new commit. This is to keep the codebase styling and fortmat consistent. |
| 95 | + |
| 96 | +You can also run the pre-commit manually. You can find all the pre-commit hooks [here](.pre-commit-config.yaml). |
| 97 | + |
| 98 | +``` |
| 99 | +pre-commit run |
| 100 | +``` |
| 101 | + |
| 102 | +Please also see our [CONTRIBUTING](CONTRIBUTING.md) guide for other information. |
| 103 | + |
| 104 | +## Changelog |
| 105 | +See [Changelog](CHANGELOG.md) |
| 106 | + |
| 107 | +## License |
| 108 | +See [License](LICENSE.txt) |
0 commit comments