Git Product home page Git Product logo

mkm-sdk's Introduction

Magic Kard Market Python SDK

image

image

image

image

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]{.title-ref} and [MKM_ACCESS_TOKEN_SECRET]{.title-ref} need to be set to empty string if you want to use a widget app.

Usage

First thing to do is import the [Mkm]{.title-ref} 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]{.title-ref} 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]{.title-ref} and [MKM_ACCESS_TOKEN_SECRET]{.title-ref} are empty strings or not.

mkm-sdk's People

Contributors

danielmaly avatar dependabot[bot] avatar lukegothic avatar masci avatar psykopear avatar silvanocerza avatar sukicz avatar szilveszter avatar

Stargazers

 avatar

Watchers

 avatar  avatar

Forkers

sukicz

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.