Skip to content
Python SDK for Magickartenmarkt API
Python
Branch: master
Clone or download
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
docs Bumped version to 0.5.3 Aug 8, 2019
mkmsdk Bumped version to 0.5.3 Aug 8, 2019
requirements Removed black as dev dependency Dec 8, 2018
tests Tested Api handling of auth_params Jun 13, 2019
.coveragerc Added coveralls config Feb 18, 2015
.gitignore Added black code formatter Dec 6, 2018
.travis.yml Fixed travis.yml again Dec 6, 2018
LICENSE Updated setup.py Oct 16, 2016
MANIFEST.in Updated Readme, setup, tox. Added documentation for Read The Docs Feb 16, 2015
README.rst Updated documentation Dec 18, 2018
contributors.txt Initial commit with contributors Feb 2, 2015
mkdocs.yml migrated to mkdocs from sphynx Aug 26, 2016
runtest.py Migrated all tests to pytest Aug 15, 2016
setup.py
tox.ini Updated base python Dec 5, 2018

README.rst

Magic Kard Market Python SDK

https://badge.fury.io/py/mkmsdk.png https://readthedocs.org/projects/mkm-sdk/badge/?version=latest

A simple SDK for dedicated and widget apps working with Magic Kard Market.

Contributing

Feel free to contribute! Submit a PR following the guidelines and it will be alright.

Requirements

Setup

From the command line:

pip install mkmsdk

For the SDK to work properly you need to create four environment variables holding the tokens necessary to create the authorization to make requests. You can find them in your Magic Kard Market account page under the apps section.

  • MKM_APP_TOKEN
  • MKM_APP_SECRET
  • MKM_ACCESS_TOKEN
  • MKM_ACCESS_TOKEN_SECRET

MKM_ACCESS_TOKEN and MKM_ACCESS_TOKEN_SECRET need to be set to empty string if you want to use a widget app.

Usage

First thing to do is import the Mkm class and the API map:

from mkmsdk.mkm import Mkm
from mkmsdk.api_map import _API_MAP

Instance a new instance of Mkm:

# Using API v1.1
mkm = Mkm(_API_MAP["1.1"]["api"], _API_MAP["1.1"]["api_root"])
# Using API v2.0
mkm = Mkm(_API_MAP["2.0"]["api"], _API_MAP["2.0"]["api_root"])

If you want to test on Magic Card Market's sandbox you must use the sandbox root endpoint:

mkm_sandbox = Mkm(_API_MAP["2.0"]["api"], _API_MAP["2.0"]["api_sandbox_root"])

To make a request:

response = mkm.account_management.account()

# Formats an endpoint
response = mkm.market_place.user(user='SampleUser')

# Call endpoint with specified parameters
response = mkm.account_management.vacation(params={"onVacation": "false"})

This will return a Response object that contains the response from the server.

Note that only market_place requests work when using a widget app.

To get a json you can call response.json().

Tests

Integration tests will be skipped if the four environment variables are not set.

  • MKM_APP_TOKEN
  • MKM_APP_SECRET
  • MKM_ACCESS_TOKEN
  • MKM_ACCESS_TOKEN_SECRET

Note that some tests will be skipped depending if MKM_ACCESS_TOKEN and MKM_ACCESS_TOKEN_SECRET are empty strings or not.

You can’t perform that action at this time.